webapck 配置vue解析報錯 Module parse failed: Unexpected character '#'


錯誤提示:

Module parse failed: Unexpected character '#' (20:0)
File was processed with these loaders:
* ./node_modules/vue-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|
|
> #app {
| font-family: Avenir, Helvetica, Arial, sans-serif;
| -webkit-font-smoothing: antialiased;
@ ./src/App.vue 4:0-63
@ ./src/main.js 2:0-27 9:17-20

webpack loader配置:

    {
        test: /\.vue$/,
        use: ["vue-loader"],
      }
 
原因分析:
以前用vue-loader解析.vue沒有問題,現在卻在報錯,那么可以從新版本特性上入手

 

解決方法:

 vue-loader@15.*之后除了必須帶有VueLoaderPlugin 之外,還需另外單獨配置css-loader。

 1 const VueLoaderPlugin = require("vue-loader/lib/plugin");
 2 {
 3         test: /\.vue$/,
 4         use: ["vue-loader"],
 5       },
 6       {
 7         test: /\.css$/,
 8         use: [
 9           'style-loader',
10           'css-loader'
11         ]
12  }
13 plugins: [
14     new VueLoaderPlugin()
15 ],

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM