The project is about to go into production, but I found that the production environment can still be seen in the debugging mode of chrome.vue-devtools
How should I configure my webpack?
Note: My project is useless vue-cli
is simply webpack vue-loader
packaging. The following is my code:
var webpack = require("webpack");
var path = require("path");
module.exports = {
/**
* devtool
* 开发者工具 debug用 生产环境要取消
*/
cache: false,
debug: false,
/**
* webpack 基础配置
*/
entry: __dirname + "/../app/main.js", //入口文件
output: {
filename: "build.js",
path: path.resolve(__dirname, "../dist"),
publicPath: '/dist/'
},
/**
* module
*/
module: {
loaders: [
{
test: /\.vue$/,
loader: 'vue'
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
},
{
test: /\.css$/,
loader: 'style-loader!css-loader',
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url',
query: {
limit: 6000,
name: 'assets/[name]_[hash:8].[ext]'
}
}
]
},
vue: {
loaders: {
js: 'babel',
}
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.js'
}
},
babel: {
presets: ['es2015', 'stage-0'],
plugins: ['transform-runtime']
}
};
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = false;
module.exports.plugins = [
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production")
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin()
];
} else {
module.exports.devtool = '#source-map'
}
Solved it myself.