Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在vue文件里import css文件出错 #8

Open
samoyi opened this issue Apr 12, 2018 · 0 comments
Open

在vue文件里import css文件出错 #8

samoyi opened this issue Apr 12, 2018 · 0 comments

Comments

@samoyi
Copy link
Owner

samoyi commented Apr 12, 2018

 error  in ./node_modules/swiper/dist/css/swiper.css

Module build failed: Unknown word (5:1)

  3 | // load the styles
  4 | var content = require("!!../../../css-loader/index.js??ref--9-1!../../../postcss-loader/lib/index.js??ref--9-2!./swiper.css");
> 5 | if(typeof content === 'string') content = [[module.id, content, '']];
    | ^
  6 | if(content.locals) module.exports = content.locals;
  7 | // add the styles to the DOM
  8 | var update = require("!../../../vue-style-loader/lib/addStylesClient.js")("6a08eb01", content, false, {});


 @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/components/index/awesome-swiper.vue 19:0-36
 @ ./src/components/index/awesome-swiper.vue
 @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/components/index.vue
 @ ./src/components/index.vue
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js

可以看出来,在build css文件的时候,发现了unknown word,而且是js代码。
因为这个css已经被build过一次了,从css文件构建成了js文件,再次build时当然会出错。
vue-loader可以加载其中import的css文件,而我在webpack的配置里面又针对css文件使用了css-loader进行加在,导致了重复。删除对css文件的配置loader配置即可。

参考以下两个链接:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant