优化CSS插件无法针对生产模式webpack@4.16.3构建

时间:2019-02-05 06:57:13

标签: css webpack webpack-plugin

该构建在开发模式下按预期运行,但在生产模式下失败。

配置:

 optimization: {
  minimizer: [
  new UglifyJsPlugin({
    cache: true,
    parallel: true,
  }),
  new OptimizeCSSAssetsPlugin({
    cssProcessorPluginOptions: {
      preset: ['default', { discardComments: { removeAll: true } }],
    },
  }),
],

},

仅在生产模式下错误:

JisonLexerError: Lexical error on line 1: Unrecognized text.

Erroneous area:
1: width * 1.75
^..^
at /Users/evive/IdeaProjects/CampaignsFrontEnd/campaigns-frontend/css/myevive-4592690b255cd15c7dbd.min.css:3961:5
at Object.parseError (/Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/cssnano-preset-default/node_modules/postcss-calc/dist/parser.js:1164:15)
at Object.lexer_parseError [as parseError] (/Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/cssnano-preset-default/node_modules/postcss-calc/dist/parser.js:2297:44)
at Object.lexer_next [as next] (/Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/cssnano-preset-default/node_modules/postcss-calc/dist/parser.js:3292:22)
at Object.lexer_fastLex [as fastLex] (/Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/cssnano-preset-default/node_modules/postcss-calc/dist/parser.js:3367:18)
at fastLex (/Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/cssnano-preset-default/node_modules/postcss-calc/dist/parser.js:1567:27)
at Parser.parse (/Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/cssnano-preset-default/node_modules/postcss-calc/dist/parser.js:1641:30)
at /Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/cssnano-preset-default/node_modules/postcss-calc/dist/lib/transform.js:30:30
at walk (/Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/postcss-value-parser/lib/walk.js:19:7)
at ValueParser.walk (/Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/postcss-value-parser/lib/index.js:18:3)
at transformValue (/Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/cssnano-preset-default/node_modules/postcss-calc/dist/lib/transform.js:24:50)
at _default (/Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/cssnano-preset-default/node_modules/postcss-calc/dist/lib/transform.js:59:100)
at /Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/cssnano-preset-default/node_modules/postcss-calc/dist/index.js:25:51
at /Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/postcss/lib/container.js:135:18
at Rule.each (/Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/postcss/lib/container.js:101:16)
at Rule.walk (/Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/postcss/lib/container.js:131:17)
at /Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/postcss/lib/container.js:148:24
at AtRule.each (/Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/postcss/lib/container.js:101:16)
at AtRule.walk (/Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/postcss/lib/container.js:131:17)
at /Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/postcss/lib/container.js:148:24
at Root.each (/Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/postcss/lib/container.js:101:16)
at Root.walk (/Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/postcss/lib/container.js:131:17)
at /Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/cssnano-preset-default/node_modules/postcss-calc/dist/index.js:23:9
at initializePlugin (/Users/evive/IdeaProjects/CampaignsFrontEnd/node_modules/optimize-css-assets-webpack-plugin/node_modules/cssnano/dist/index.js:31:51)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:160:7)

生产模式需要其他配置吗?还是需要更改?

0 个答案:

没有答案