Css无法使用vue webpack-simple进行解析

时间:2016-12-10 19:53:47

标签: javascript webpack vue.js

我已经创建了一个webpack-simple项目,如下所述:https://github.com/vuejs-templates/webpack-simple

接下来,我使用npm install vue-codemirror --save安装了vue-codemirror(link)。在main.js中,导入并使用vue-codemirror。

import CodeMirror from 'vue-codemirror';
Vue.use(CodeMirror);

但是,运行npm run dev会导致所有codemirrror css出错。错误都是这样的:

ERROR in ./~/codemirror/addon/dialog/dialog.css
Module parse failed: C:\Users\aidan\Code\ludum-dare-37\node_modules\codemirror\addon\dialog\dialog.css Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
| .CodeMirror-dialog {
|   position: absolute;
|   left: 0; right: 0;
 @ ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./~/vue-codemirror/codemirror.vue 99:6-51
 @ ./~/vue-codemirror/codemirror.vue
 @ ./~/vue-codemirror/index.js
 @ ./src/main.js
 @ multi main

1 个答案:

答案 0 :(得分:3)

我需要安装style-loader

npm install style-loader --save-dev

然后将其添加到webpack.config.js。具体来说,我添加了以下模块规则:

{
    test: /\.css$/,
    loader: "style-loader!css-loader"
},