webpack-dev-server打包的代码要比webpack打包的代码小很多,为什么?
上配置:
module.exports = {
entry: {
app: './src/index.jsx',
vendor: [
'inferno',
'inferno-router',
'inferno-redux',
'inferno-component',
'whatwg-fetch'
]
},
devServer: {
contentBase: path.resolve(__dirname, './build/'),
compress: true,
port: 80,
hot: true,
inline: true
// https: true
},
output: {
path: path.resolve(__dirname, './build/'),
publicPath: '/build/',
filename: '[name].js',
chunkFilename: '[name].[hash].js'
},
resolve: {
modules: [
'src',
'node_modules'
],
extensions: ['.css', '.scss', '.js', '.jsx']
},
module: {
rules: [{
test: /\.html$/,
use: [{
loader: 'file-loader'
}]
}, {
test: /\.(js|jsx)$/,
exclude: [/node_modules/],
use: [{
loader: 'babel-loader',
options: {
presets: ['es2015'],
plugins: ['transform-runtime', 'syntax-dynamic-import', 'inferno']
}
}]
}, {
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
includePath: path.resolve(__dirname, 'node_modules/compass-mixins/lib')
}
}
]
}, {
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader',
publicPath: '/build/'
})
}, {
test: /\.(png|jpg|gif)$/,
use: [{
loader: 'url-loader',
options: {
limit: 5000
}
}]
}, {
test: /\.(eot|svg|ttf|woff|woff2)\??.*$/,
loader: 'url-loader',
options: {
name: 'fonts/[name].[md5:hash:hex:7].[ext]'
}
}]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new CommonsChunkPlugin({
name: 'vendor',
filename: 'vendor.js',
minChunks: 2
}),
new ExtractTextPlugin({
filename: 'bundle.css',
disable: false,
allChunks: true
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify("production")
}
}),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
},
comments: false,
sourceMap: true,
minimize: true
}),
new HtmlWebpackPlugin({
title: 'loading',
has: true,
inject: true,
chunks: ['app', 'vendor'],
template: 'index.ejs'
})
]
};
用webpack-dev-server开发的时候,从http请求看
但是用webpack打包的时候,体积大很多
这是因为gzip的原因么?
还是哪里配置不对……
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
开启了
Gzip
压缩