在捆绑css
和js
时出现错误。捆绑后 CSS文件为大,尽管初始css
文件大小相等捆绑后达到16 kb,最高可达438kb。
这里有一些警告,在捆绑cmd后显示。
WARNING in asset size limit: The following asset(s) exceed the recommended size limit (250 kB).
This can impact web performance.
Assets:
style.css (448 kB)
WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (250 kB). This can impact web performance.
Entrypoints:
main (456 kB)
bundle.js
style.css
WARNING in webpack performance recommendations:
You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
For more info visit https://webpack.js.org/guides/code-splitting/
这是我的 webpack.config.js
const path = require("path");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const NODE_ENV = process.env.NODE_ENV || "development";
const webpack = require("webpack");
const config = {
entry: "./common.js",
output: {
path: path.resolve(__dirname, "dist"),
filename:"bundle.js"
},
// performance: {
// maxEntrypointSize:400000
// },
module: {
rules: [
{
use:"babel-loader",
test: /\.js$/,
},
{
loader:ExtractTextPlugin.extract({
loader:"css-loader"
// options: {minimize:true}
}),
test: /\.css$/,
},
{
test: /\.(jpe?g|png|gif|svg)$/,
use: [
{
loader:"url-loader"
// options:{ limit:40000 }
},
"image-webpack-loader"
]
}
]
},
plugins: [
new ExtractTextPlugin("style.css")
]
};
if (NODE_ENV == "production") {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress:{
warnings:false,
drop_console:true,
unsafe:true
}
})
);
}
module.exports = config;