I realize this task by using two files robots-open.txt
and robot-closed.txt
and setting ENV variable.
Ad then add WebPackPlugin into quasar.config.js
as written above:
extendWebpack(cfg) {
const robotsMode =
process.env.OPEN_FOR_ROBOTS === 'true' ? 'opened' : 'closed'
console.log(`==> Robots.txt are ${robotsMode}`)
cfg.plugins.push(
new CopyWebpackPlugin({
patterns: [
{
from: `robots/robots-${robotsMode}.txt`,
to: 'robots.txt',
},
],
}),
)
},