zoukankan      html  css  js  c++  java
  • webpack4配置

    新版本的webpack@4在打包之后默认是对js进行了压缩的,那么如何设置不自动压缩呢,这需要用到webpack的mode配置

    mode

    提供模块化的配置选项告诉webpack使用相应的优化选项。当不对它进行配置的时候,默认值是"production",我们只需要将该值设置为"development",则webpack则不会对打包后的js文件进行压缩,示例:

    // webpack.config.js
    module.exports = { 
    	mode: "development"
    }
    

    mode可选的值如下:

    描述
    development 会将 process.env.NODE_ENV 的值设为 development。启用 NamedChunksPlugin 和 NamedModulesPlugin
    production (默认)会将 process.env.NODE_ENV 的值设为 production。启用 FlagDependencyUsagePlugin, FlagIncludedChunksPlugin, ModuleConcatenationPlugin, NoEmitOnErrorsPlugin, OccurrenceOrderPlugin, SideEffectsFlagPlugin 和 UglifyJsPlugin
    none 不设置任何自动优化配置

    记住,只设置 NODE_ENV,则不会自动设置 mode

    各个值对应的详细配置见下文.

    Mode: development

    // webpack.development.config.js
    module.exports = {
    + mode: 'development'
    - devtool: 'eval',
    - cache: true,
    - performance: {
    -   hints: false
    - },
    - output: {
    -   pathinfo: true
    - },
    - optimization: {
    -   namedModules: true,
    -   namedChunks: true,
    -   nodeEnv: 'development',
    -   flagIncludedChunks: false,
    -   occurrenceOrder: false,
    -   sideEffects: false,
    -   usedExports: false,
    -   concatenateModules: false,
    -   splitChunks: {
    -     hidePathInfo: false,
    -     minSize: 10000,
    -     maxAsyncRequests: Infinity,
    -     maxInitialRequests: Infinity,
    -   },
    -   noEmitOnErrors: false,
    -   checkWasmTypes: false,
    -   minimize: false,
    -   removeAvailableModules: false
    - },
    - plugins: [
    -   new webpack.NamedModulesPlugin(),
    -   new webpack.NamedChunksPlugin(),
    -   new webpack.DefinePlugin({ "process.env.NODE_ENV": JSON.stringify("development") }),
    - ]
    }
    

    Mode: production

    // webpack.production.config.js
    module.exports = {
    +  mode: 'production',
    - performance: {
    -   hints: 'warning'
    - },
    - output: {
    -   pathinfo: false
    - },
    - optimization: {
    -   namedModules: false,
    -   namedChunks: false,
    -   nodeEnv: 'production',
    -   flagIncludedChunks: true,
    -   occurrenceOrder: true,
    -   sideEffects: true,
    -   usedExports: true,
    -   concatenateModules: true,
    -   splitChunks: {
    -     hidePathInfo: true,
    -     minSize: 30000,
    -     maxAsyncRequests: 5,
    -     maxInitialRequests: 3,
    -   },
    -   noEmitOnErrors: true,
    -   checkWasmTypes: true,
    -   minimize: true,
    - },
    - plugins: [
    -   new TerserPlugin(/* ... */),
    -   new webpack.DefinePlugin({ "process.env.NODE_ENV": JSON.stringify("production") }),
    -   new webpack.optimize.ModuleConcatenationPlugin(),
    -   new webpack.NoEmitOnErrorsPlugin()
    - ]
    }

    Mode: none

    // webpack.custom.config.js
    module.exports = {
    + mode: 'none',
    - performance: {
    -  hints: false
    - },
    - optimization: {
    -   flagIncludedChunks: false,
    -   occurrenceOrder: false,
    -   sideEffects: false,
    -   usedExports: false,
    -   concatenateModules: false,
    -   splitChunks: {
    -     hidePathInfo: false,
    -     minSize: 10000,
    -     maxAsyncRequests: Infinity,
    -     maxInitialRequests: Infinity,
    -   },
    -   noEmitOnErrors: false,
    -   checkWasmTypes: false,
    -   minimize: false,
    - },
    - plugins: []
    }

    转自 https://blog.csdn.net/huzhenv5/article/details/105151480

  • 相关阅读:
    phpstorm 2017 关掉变量提示 parameter name hints,改变打开方式
    RMAN-06496: must use the TO clause when the database is mounted or open
    FAL[client]: Failed to request gap sequence GAP
    搭建rac对单实例的MAA
    Linux下安装Oracle 10g(redhat 4)
    ora-01031:insufficient privileges
    ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
    checking for oracle home incompatibilities failed
    用root帐号切换其他帐号提示 su: warning: cannot change directory to /home/oracle: Permission denied
    an error occured during the file system check
  • 原文地址:https://www.cnblogs.com/zhishaofei/p/13837351.html
Copyright © 2011-2022 走看看