从外部库导入css文件的Vue.js webpack错误

时间:2018-02-04 13:46:32

标签: webpack vue.js css-loader

我正在尝试将aos(动画库)导入我的测试应用

我安装它通常纱线添加aos 在我的vue中,我使用以下代码

<script>
....
import AOS from 'aos/dist/aos.js'
import 'aos/dist/aos.css'

methods: {
...
installAos: function () {
  const aos = new AOS({ duration: 1200 })
  aos.init()
}, 
mounted: function () {
this.$nextTick(function () {
  ....
  this.installAos()
})
}

我在构建w webpack(3.6.0)时遇到错误

警告编制了1个警告14:36:15

 warning  in ./node_modules/aos/dist/aos.css

 (Emitted value instead of an instance of Error)   resolve-url-loader cannot operate: CSS error
  ENOENT: no such file or directory, open '/Users/yves/Developments  /WIP/VUE.JS/hello-vue/node_modules/a
os/dist/aos.css.map'
    at Object.fs.openSync (fs.js:646:18)

似乎与外部css文件的加载有关.. 没有aos.css.map

1 个答案:

答案 0 :(得分:0)

为什么......

aos.css包末尾的注释行:

/*# sourceMappingURL=aos.css.map*/

如果我压制这一行,那么它正确构建

我不明白为什么这行由resolve-url-loader插件检查...我将把它作为一个问题写入resolve-url-loader支持团队...