[英]How to minimize javascript with Webpack?
I'm trying to minimize my bundle.js file with webpack, but getting errors in my config: 我正在尝试使用webpack最小化我的bundle.js文件,但在配置中出现错误:
module.exports = {
entry: "./entry.js",
output: {
devtoolLineToLine: true,
sourceMapFilename: "./bundle.js.map",
pathinfo: true,
path: __dirname,
filename: "bundle.js"
},
module: {
loaders: [
{ test: /\.css$/, loader: "style!css" }
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
include: /\.min\.js$/,
minimize: true
})
]
};
The error: 错误:
/Users/leongaban/Projects/TickerTags/ionic/TickerTags/www/webpack.config.js:16
new webpack.optimize.UglifyJsPlugin({
^
ReferenceError: webpack is not defined
Seems like you're missing var webpack = require('webpack');
似乎您缺少var webpack = require('webpack');
at the top of your configuration file. 在配置文件的顶部。
It works for me this way 这样对我有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.