鍍金池/ 問答/Linux  HTML/ webpack 熱更新時 warnings

webpack 熱更新時 warnings

錯誤

WARNING in configuration
The 'mode' option has not been set. Set 'mode' option to 'development' or 'production' to enable defaults for this environment.

WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
  print.0989fjs (348 KiB)
  vendors.0989fjs (357 KiB)
  index.0989fjs (885 KiB)

WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
  index (885 KiB)
      index.0989fjs
  vendors (357 KiB)
      vendors.0989fjs
  print (348 KiB)
      print.0989fjs


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/

這是配置文件

const webpack = require('webpack');

module.exports = {
    // devtool: 'inline-source-map',
    devServer: {
        contentBase: './dist',
        compress:true,
        port:9000,
        host:'127.0.0.1',
        hot: true, 
       
    },
    entry: {
        index: './src/index.js',
        vendors: ['react'],
        
    },

    plugins: [
        new CleanWebpackPlugin(['dist']),
        new HTMLWebpackPlugin({
            title: 'Code Splitting'
        }),
        new webpack.NamedModulesPlugin(),
        new webpack.HotModuleReplacementPlugin()

    
    ],
    
    output: {
        filename: '[name].[hash:5]js',
        path: path.resolve(__dirname, 'dist'),
        hotUpdateChunkFilename: 'hot/hot-update.js',  //指定熱替換補丁js文件和
        hotUpdateMainFilename: 'hot/hot-update.json', //json描述文件生成路徑 ,每次文件變化都會生成一次
    }
};

要如何處理呢

回答
編輯回答
念初

你這是webpack4的配置吧 webpack4的配置現(xiàn)在要加多一個mode來判斷是開發(fā)環(huán)境還是生產(chǎn)環(huán)境
`const webpack = require('webpack');

module.exports = {

// devtool: 'inline-source-map',
    mode: "development", //加上這一句試試
devServer: {
    contentBase: './dist',
    compress:true,
    port:9000,
    host:'127.0.0.1',
    hot: true, 
   
},
entry: {
    index: './src/index.js',
    vendors: ['react'],
    
},

plugins: [
    new CleanWebpackPlugin(['dist']),
    new HTMLWebpackPlugin({
        title: 'Code Splitting'
    }),
    new webpack.NamedModulesPlugin(),
    new webpack.HotModuleReplacementPlugin()


],

output: {
    filename: '[name].[hash:5]js',
    path: path.resolve(__dirname, 'dist'),
    hotUpdateChunkFilename: 'hot/hot-update.js',  //指定熱替換補丁js文件和
    hotUpdateMainFilename: 'hot/hot-update.json', //json描述文件生成路徑 ,每次文件變化都會生成一次
}

};`

2017年1月30日 04:21
編輯回答
清夢

嗯嗯 好用了 但是為啥我的頁面并沒有更新呢

2017年12月5日 06:18