asfktz / autodll-webpack-plugin

Webpack's DllPlugin without the boilerplate
MIT License
1.46k stars 81 forks source link

What does [not cacheable] mean in the webpack building info? #112

Open xiangnanscu opened 6 years ago

xiangnanscu commented 6 years ago

Version: webpack 2.7.0

Hello, I encountered two problems when I run webpack --progress --config webpack.prod.js:

  1. infomation shows delegated ./node_modules/vue/dist/vue.runtime.esm.js from dll-reference vendor_81e1521a878e34171326 42 bytes {0} [not cacheable], I don't know if [not cacheable] means everytime I will repack ./node_modules/vue/dist/vue.runtime.esm.js even if I change nothing.
    Hash: 3d927c784a9cc878205a
    Version: webpack 2.7.0
    Time: 39383ms
                             Asset       Size  Chunks                    Chunk Names
                   image/zhang.png    16.3 kB          [emitted]         
           js/exam.fe1b097d5a2d.js     985 kB       0  [emitted]  [big]  main
         css/exam.2185e5ecab41.css     125 kB       0  [emitted]         main
                    html/exam.html  757 bytes          [emitted]         
    dll/vendor_62047a75952194d978aa.js     632 kB          [emitted]  [big]  
    [0] ./~/vue-loader/lib/component-normalizer.js 1.27 kB {0} [built]
    [52] delegated ./node_modules/vue/dist/vue.runtime.esm.js from dll-reference vendor_81e1521a878e34171326 42 bytes {0} [not cacheable] [built]
  2. I run the building command again and again, but the building time is almost the same.

this is my webpack config file (two files merged, both are in the root project folder):

var name = process.env.NAME || 'main' var processEnvConstants = {} for (var key in process.env) { processEnvConstants[key] = JSON.stringify(process.env[key]) }

var extractCSS if (process.env.NODE_ENV == 'production') { extractCSS = new ExtractTextPlugin(css/${name}.[contenthash:12].css) } else { extractCSS = new ExtractTextPlugin(css/${name}.css) } var POSTCSS_LOADER = { loader: 'postcss-loader', // Run post css actions options: { plugins: function () { // post css plugins, can be exported to postcss.config.js return [ require('precss'), require('autoprefixer') ]; } } } var BABEL_LOADER = { loader: 'babel-loader', options: { presets: [ ['vue-app', { "targets": { "browsers": ["ie >= 9"] } }] ], "plugins": ["transform-vue-jsx"], babelrc: false, } }

module.exports = { node: { fs: 'empty' }, resolve: { modules: [ path.resolve('./css'), path.resolve('./js'), path.resolve('./image'), path.resolve('./vue'), path.resolve('./jarsj/vue'), 'node_modules', 'js', 'vue', "css", ], alias: {

},

}, module: { rules: [{ test: /.js$/, exclude: /node_modules/, use: BABEL_LOADER, }, { test: /.css$/, use: extractCSS.extract(["css-loader"]), }, { test: /.less$/, use: extractCSS.extract(["css-loader", "less-loader"]), }, { test: /.scss$/, use: extractCSS.extract(["css-loader",POSTCSS_LOADER, "sass-loader"]), }, { test: /.vue$/, loader: 'vue-loader', options: { // extractCSS: true, loaders: { js: BABEL_LOADER, css: extractCSS.extract(["css-loader"]), less: extractCSS.extract(["css-loader", "less-loader"]), sass: extractCSS.extract(["css-loader", "sass-loader"]), // less: extractVueLESS.extract(["css-loader","less-loader"]), } // other vue-loader options go here } }, { test: /.(png|jpg|gif|jpeg)$/, loader: 'file-loader', options: { name: 'image/[name].[ext]' } }, { test: /.(svg|woff|woff2|ttf|eot)$/, loader: 'file-loader', options: { name: 'font/[name].[ext]' } }, ], }, performance: { hints: false }, plugins: [ extractCSS, new webpack.DefinePlugin({ 'process.env': processEnvConstants, }), ], }

- webpack.prod.js

var path = require('path') var webpack = require('webpack') var HtmlWebpackPlugin = require('html-webpack-plugin') const AutoDllPlugin = require('autodll-webpack-plugin'); var webpackCommon = require("./webpack.common.js") var merge = require("webpack-merge")

var name = process.env.NAME || 'main' var appFolder = process.env.APP_FOLDER || 'app'

function getOutputPath() { if (process.env.COMMON) { return path.resolve('../b/dist') } else { return path.resolve(../b/${appFolder}/dist) } }

module.exports = merge(webpackCommon, { entry: ${name}.js, externals: { // jquery: 'jQuery', // vue: 'Vue', // 'vue-resource': 'VueResource', // 'vue-router': 'VueRouter', // vuex: 'Vuex', }, output: { path: getOutputPath(), publicPath: process.env.OSS && process.env.OSSURL || '/', filename: js/${name}.[chunkhash:12].js, chunkFilename: js/${name}.[chunkhash:12].js, }, plugins: [ new webpack.optimize.UglifyJsPlugin({ sourceMap: true, compress: { warnings: false } }), new webpack.LoaderOptionsPlugin({ minimize: true }), new HtmlWebpackPlugin({ filename: html/${name}.html, // relative to output.path template: ./html/${name}.template.html, minify: {}, }), new AutoDllPlugin({ inject: true, // will inject the DLL bundle to index.html debug: true, filename: '[name][hash].js', path: './dll', entry: { vendor: [ 'vue','vuex','vue-router','vue-resource','jquery' ] } }) ],

})

if (process.env.OSS) { require('babel-polyfill') var OSSPlugin = require('webpack-oss-plugin') module.exports.plugins = (module.exports.plugins || []).concat([ new OSSPlugin({ exclude: /.*.(html|svg|woff|woff2|ttf|eot)$/, ossOptions: { accessKeyId: process.env.OSS_ACCESS_KEY, accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET, region: process.env.OSS_REGION, bucket: process.env.OSS_BUCKET, }, ossUploadOptions: {}, }), //// more plugins ]) }