Closed kfirba closed 6 years ago
I'd be curious as well to learn more about production environment configuration. I imagine we'd need to add some config to vue-loader
(https://github.com/vuejs/laravel-elixir-vue-2/blob/master/index.js#L21)?
gulp --production is also for me not creating real production files. Vue-devtools are still available and all warnings works as well.
No idea how to fix that?
A workaroud would be:
// Comment these three for local build.
Vue.config.devtools = false
Vue.config.debug = false
Vue.config.silent = true
As of here.
You can do this, tho.
createwebpack.config.js
in project root
var webpack = require('webpack')
module.exports = {
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
})
]
}
In case you don't know: laravel-elixir will merge your self-defined webpack.config.js
into itself.
in your code:
Vue.config.devtools = process.env.NODE_ENV !== 'production'
Vue.config.debug = process.env.NODE_ENV !== 'production'
Vue.config.silent = process.env.NODE_ENV === 'production'
Whenever you try to switch to development/production mode, just re-set the value in webpack.DefinePlugin
Depending on your setup, you can create a webpack.config.js
file as @ZhihaoLau wrote but instead of setting your staging directly you could use the "real" NODE_ENV
env var like this:
var webpack = require('webpack')
module.exports = {
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
})
]
}
This way, you do something like this:
export NODE_ENV=production && gulp --production
Hey.
Probably a stupid question, but I will ask it anyways:
Is this plugin configuring elixir and telling it to compile Vue and strip any warning (perhaps also translate templates to render functions) when elixir is running with the production flag?