webpack 4:默认配置

时间:2022-05-07 20:50:56

webpack 4:默认配置

  • entry 默认: ./src/index.js(注意: 路径必须带上./);

    entry: './src/index.js',
  • output 默认最后路径: ./dist/main.js(注意: 路径必须带上./);
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'main.js'
}
  • mode 默认:'production'

    可选值:production、development、none

    https://webpack.docschina.org/concepts/mode/

    production:在生产环境开启压缩和优化,启用 FlagDependencyUsagePlugin, FlagIncludedChunksPlugin, ModuleConcatenationPlugin, NoEmitOnErrorsPlugin, OccurrenceOrderPlugin, SideEffectsFlagPlugin 和 UglifyJsPlugin。

    development:启用 NamedChunksPlugin 和 NamedModulesPlugin。

    mode: 'production'

  • webpack 命令默认:webpack等价于webpack --config webpack.config.jswebpack --config webpackfile.js

  • 参考:https://www.kancloud.cn/cris/wp/595599