zoukankan      html  css  js  c++  java
  • Vue npm run build 错误 CssSyntaxError:xxxx.Unknown word

    错误提示

    building for production...Error processing file: static/css/app.df86e347a94aed52aa7bb0b865b3f053.css
    (node:8868) UnhandledPromiseRejectionWarning: CssSyntaxError: D:WorkspaceTestExercisevueDemovue-modulestaticcssapp.df86e347a94aed52aa7bb0b865b3f053.css:49:45: Unknown word
        at Input.error (D:WorkspaceTestExercisevueDemovue-module
    ode_modulesoptimize-css-assets-webpack-plugin
    ode_modulespostcsslibinput.js:130:16)
        at Parser.unknownWord (D:WorkspaceTestExercisevueDemovue-module
    ode_modulesoptimize-css-assets-webpack-plugin
    ode_modulespostcsslibparser.js:563:22)
        at Parser.decl (D:WorkspaceTestExercisevueDemovue-module
    ode_modulesoptimize-css-assets-webpack-plugin
    ode_modulespostcsslibparser.js:235:16)
        at Parser.other (D:WorkspaceTestExercisevueDemovue-module
    ode_modulesoptimize-css-assets-webpack-plugin
    ode_modulespostcsslibparser.js:133:18)
        at Parser.parse (D:WorkspaceTestExercisevueDemovue-module
    ode_modulesoptimize-css-assets-webpack-plugin
    ode_modulespostcsslibparser.js:77:16)
        at parse (D:WorkspaceTestExercisevueDemovue-module
    ode_modulesoptimize-css-assets-webpack-plugin
    ode_modulespostcsslibparse.js:17:12)
        at new LazyResult (D:WorkspaceTestExercisevueDemovue-module
    ode_modulesoptimize-css-assets-webpack-plugin
    ode_modulespostcssliblazy-result.js:60:16)
        at Processor.<anonymous> (D:WorkspaceTestExercisevueDemovue-module
    ode_modulesoptimize-css-assets-webpack-plugin
    ode_modulespostcsslibprocessor.js:138:12)
        at Processor.process (D:WorkspaceTestExercisevueDemovue-module
    ode_modulesoptimize-css-assets-webpack-plugin
    ode_modulespostcsslibprocessor.js:117:23)
        at Function.creator.process (D:WorkspaceTestExercisevueDemovue-module
    ode_modulesoptimize-css-assets-webpack-plugin
    ode_modulespostcsslibpostcss.js:148:43)
        at OptimizeCssAssetsPlugin.processCss (D:WorkspaceTestExercisevueDemovue-module
    ode_modulesoptimize-css-assets-webpack-pluginindex.js:63:19)
        at Object.processor (D:WorkspaceTestExercisevueDemovue-module
    ode_modulesoptimize-css-assets-webpack-pluginindex.js:29:23)
        at D:WorkspaceTestExercisevueDemovue-module
    ode_moduleslast-call-webpack-pluginindex.js:139:8
        at arrayEach (D:WorkspaceTestExercisevueDemovue-module
    ode_moduleslodash\_arrayEach.js:15:9)
        at forEach (D:WorkspaceTestExercisevueDemovue-module
    ode_moduleslodashforEach.js:38:10)
        at LastCallWebpackPlugin.process (D:WorkspaceTestExercisevueDemovue-module
    ode_moduleslast-call-webpack-pluginindex.js:136:3)
    (node:8868) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
    (rejection id: 2)
    (node:8868) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    

    错误介绍

    这个错误是执行npm run build 编译打包时候出现的报错。
    第一次看到的确很懵,告诉我这个问题件有个unkown word 有个不识别的单词,估计就是什么单词或者写错了吧。现在关键的是在dist目录下没有这个css文件。都没有文件生成。

    错误提示

    解决方法

    遇到这种情况,一个项目要是出现这种单词写错了,而且npm run dev 的时候也不报错。直接去一个文件一个文件的找肯定遭不住、所以找了很久的资料,终于看到一个大佬说修改一下webpack.prod.conf里的一段代码就可以了。然后重新打包就能打包成功。最后再到生成的css文件中去看到在多少行。再去对应的源文件里面修改。
    
    // 在webpack.prod.conf中找到这个暂时注释掉。解决问题后再放开
    //new OptimizeCSSPlugin({
    // cssProcessorOptions: config.build.productionSourceMap
    //? { safe: true, map: { inline: false } }
    // : { safe: true }
    //}),
    

    最后解决问题后。及得把注释放开。我的问题是在样式里面用了
    //注释

  • 相关阅读:
    [Swift]LeetCode374. 猜数字大小 | Guess Number Higher or Lower
    [Swift]LeetCode371. 两整数之和 | Sum of Two Integers
    [Swift]LeetCode367. 有效的完全平方数 | Valid Perfect Square
    [Swift]LeetCode350. 两个数组的交集 II | Intersection of Two Arrays II
    [Swift]LeetCode349. 两个数组的交集 | Intersection of Two Arrays
    [Swift实际操作]七、常见概念-(9)使用定时组件Timer执行定时任务
    [Swift实际操作]七、常见概念-(8)日历Calendar和时区TimerZone
    浅谈广告交易系统
    浅谈广告交易系统
    6种排序算法的简洁实现:冒泡、选择、插入、归并、快速、堆
  • 原文地址:https://www.cnblogs.com/justyouadmin/p/12744704.html
Copyright © 2011-2022 走看看