亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

vue.js - laravel-elixir 3: The compiled file of .browserify() reported that the dependent file cannot be found: undefined
淡淡煙草味
淡淡煙草味 2017-05-16 16:50:14
0
1
747
# 相關配置版本:
laravel 5.1 LTS
laravel-elixir 3
vue 1.0.26
vue-router 2.0.0
vue-resources 1.0.3

Use browserify that comes with laravel-elixir to compile vue, vue-router, vue-resourceAfter successfully outputting the js file, an error is reported when using it: Uncaught TypeError: Cannot read property 'use' of undefined

The compiled js file is partially as follows:

var Vue = require("vue");
var VueRouter = require('vue-router');
var VueResource = require('vue-resource');

Vue.use(VueRouter);
Vue.use(VueResource);
gulpfile.js
// 局部
elixir(function(mix) {
    mix.browserify('index.js', 'public/dist/js/index.js');
    mix.browserify('new.js', 'public/dist/js/new.js');
});

Problem:
The two files compiled above depend on the same require configuration. Index.js can be used, but new.js will report an error. Check each dependency separately through console.log(). Vue in new.js is undefined. I don’t know if it is possible. What's the reason, or how to find out where the problem is?

In addition, how to make vue These dependencies only need to be loaded once, and do not need to be packaged together in the file. I configured browser-shim, but it seems to have no effect. I don’t know why. I used it wrong or something:

package.json
"browserify": {
    "transform": [
      "vueify",
      "browserify-shim",
      "stringify"
    ]
  },
  "browserify-shim": {
    "bootstrap-sass": {
      "depends": [
        "jquery:jQuery"
      ]
    },
    "vue": "global:Vue"
  }
淡淡煙草味
淡淡煙草味

reply all(1)
某草草

Finally found the cause of the problem (expression: bursting into tears)
index.js里的Vue可正常使用,而new.jsVue則是undefined,猜測難道它不可以多次require,但是VueRouter, VueResource也重復require了,卻是可用的,思索再三,想起可能是因為package.json里寫了一句把VueSet it as a global variable, so I removed the sentence, compiled it again, and found that it was successful (what a side effect of half-knowledge==). The removed setting is as follows:

"browserify-shim": {
    ...
    "vue": "global:Vue"
}

PS: Thanks to my friend Vicent Ye for helping me find the problem.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template