Code20k
2017-04-28 10:21
为什么有的模块被标记上 [not cacheable],而且多打了很多模块 ,跟老师做的不一样,现在做到处理完less

var htmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
module.exports = {
context: __dirname,
entry: './src/app.js',
output: {
path: './dist',
filename: 'js/[name].bundle.js'
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
include: path.resolve(__dirname, 'src'),
exclude: path.resolve(__dirname, 'node_modules'),
query: {
presets: ['latest']
}
},
{
test: /\.css$/,
loader: 'style!css?importLoaders=1!postcss'
},
{
test: /\.less$/,
loader: 'style!css!postcss!less'
}
]
},
postcss: [
require('autoprefixer')({
browsers: ['last 5 versions']
})
],
plugins: [
new htmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: 'body'
})
]
}
但是不清楚为什么会把lodash打包进去

自问自答:发现好像是 include 和 exclude 的路径写的有问题
exclude:path.resolve(__dirname,'/node_modules/'), include:path.resolve(__dirname,'/src/'),
之前的 node_modules 和 src 不带 / /
webpack深入与实战
86554 学习 · 750 问题
相似问题