在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML5  HTML/ webpack 啟用熱更新后 如何避免每次都生成描述文件json和補(bǔ)丁文件js

webpack 啟用熱更新后 如何避免每次都生成描述文件json和補(bǔ)丁文件js

var path = require("path");
var CleanWebpackPlugin = require('clean-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var webpack = require('webpack'); // 引入 webpack 便于調(diào)用其內(nèi)置插件

// console.log(CleanWebpackPlugin);

module.exports = {
  devtool: 'inline-source-map',
    devServer: {
        contentBase: path.resolve(__dirname, 'dist/js'),
        hot: true, // 告訴 dev-server 我們?cè)谟?HMR
        hotOnly: true, // 指定如果熱加載失敗了禁止刷新頁(yè)面 (這是 webpack 的默認(rèn)行為),這樣便于我們知道失敗是因?yàn)楹畏N錯(cuò)誤
        inline:true,

    },
    entry: {
        print:'./src/js/print.js',
        index:'./src/js/index.js'
    },
    module:{
      rules:[
        {
          test:/\.css$/,
          use:['style-loader','css-loader']
        },
      ]
    },
    plugins: [
      new CleanWebpackPlugin(['dist']),
      new HtmlWebpackPlugin({
            title: 'Output Management',
            inject:'head',
            filename:'index.html',
            template:'index.html'
      }),
        new webpack.NamedModulesPlugin(),
        new webpack.HotModuleReplacementPlugin()
    ],
    output: {
        path: path.resolve(__dirname,'./dist'),
        filename: '[name].bundle.js',
        // chunkFilename:'[name].bundle.js',
    },
};

clipboard.png每次都會(huì)生成這些文件 如何配置不生成呢

回答
編輯回答
醉淸風(fēng)

Those HMR chunks are created by HotModuleReplacementPlugin when we use --watch flag running webpack:
webpack -d --watch

The best way I found till now is to define specific folder and file for those chunks. We can do this in the output section, for example:

output: {
    path: path.join(root, "dist"),
    filename: "bundle.js",
    hotUpdateChunkFilename: 'hot/hot-update.js',
    hotUpdateMainFilename: 'hot/hot-update.json'
}

After this change, we will have only those two files created. So we can simply add them (or whole folder) to the .gitignore.

I know It's not the best solution, but I didn't found anything better for now.

2017年9月30日 00:15