添加bower组件以vue webpack

时间:2017-01-20 10:53:08

标签: bower vuejs2 vue.js

有没有办法将bower_components添加到vue-webpack。 我试过某种方式它不起作用。

webpack.base.conf.js
http://pastebin.com/Gae193xP
组件文件

select `field(s)` from table where .... limit x

错误 enter image description here

2 个答案:

答案 0 :(得分:0)

您应该从要使用它的位置加载脚本文件。 Webpack将加载它并将其包含在build.js

<-- componentX.vue -->
...
<script lang="js">
import jquery from "../bower_components/jquery/jquery.js";

...
</script>

答案 1 :(得分:0)

您应该配置webpack配置文件以解决来自bower的软件包。例如,在webpack.config.js

module.exports = {
  resolve: {
    modulesDirectories: ["web_modules", "node_modules", "bower_components"]
  },
  plugins: [
    new webpack.ResolverPlugin(
        new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin(".bower.json", ["main"])
      )
  ]
}

您可以参考https://webpack.github.io/docs/usage-with-bower.html