问答详情
源自:-

模块被标记上 [not cacheable],而且多打了很多未知模块

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

http://img.mukewang.com/5902a60000016b0a14801066.jpg

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'
        })
    ]
}


提问者:Code20k 2017-04-28 10:21

个回答

  • Code20k
    2017-04-28 10:42:54

    但是不清楚为什么会把lodash打包进去

    http://img.mukewang.com/5902ac29000129a314640518.jpg

  • Code20k
    2017-04-28 10:41:48

    自问自答:发现好像是 include 和 exclude 的路径写的有问题

    exclude:path.resolve(__dirname,'/node_modules/'),
    include:path.resolve(__dirname,'/src/'),

    之前的 node_modules 和 src 不带 / /