Answer the question
In order to leave comments, you need to log in
Why don't production and developmeent modes work?
When I set the webpack work mode to "production" or "developmeent", I see the following error:
Here is my webpack.config.js file:
const NODE_ENV = process.env.NODE_ENV || 'development';
const webpack = require('webpack');
module.exports = {
entry: "./src",
output: {
filename: "build.js",
library: "src"
},
watch: NODE_ENV == 'development',
watchOptions: {
aggregateTimeout: 200
},
devtool: NODE_ENV == 'development' ? "cheap-inline-module-source-map" : null,
plugins: [
new webpack.DefinePlugin({
NODE_ENV: JSON.stringify(NODE_ENV)
})
],
resolve: {
modules: ["node_modules"],
extensions: ["*", ".js"]
},
resolveLoader: {
modules: ["node_modules"],
moduleExtensions: ['-loader'],
extensions: ["*", ".js"]
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader'
}
}
]
}
};
if(NODE_ENV == 'production') {
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
optimization: {
minimizer: [
// we specify a custom UglifyJsPlugin here to get source maps in production
new UglifyJsPlugin({
cache: true,
parallel: true,
uglifyOptions: {
compress: false,
ecma: 6,
mangle: true
},
sourceMap: true
})
]
}
};
}
Answer the question
In order to leave comments, you need to log in
It says in plain text that the devtool key must be string or false . At you in a production mode on a condition null
Learn to read the text of errors.
Learn to google errors if their text is not entirely clear how to fix them.
If you don't know English, learn.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question