VueJS: Import global?

How to tie a vue to the cli global imports?

https://github.com/terpiljenya/import-glob#readme

I failed to configure correctly vue.config.js
March 20th 20 at 11:21
2 answers
March 20th 20 at 11:23
Good day!

The contents vue.config.js:
module.exports = {
 configureWebpack: {
 module: {
 rules: [{
 test: /\.js/,
 loader: 'import-glob'
},
{
 test: /\.scss/,
 loader: 'import-glob'
}
]
}
}
}


The src folder:
src/
├── App.vue
...
│ 
├── lib
│ ├── example
│ │ └── example.js # example2
│ └── example.js # example1
└── main.js


Files example.js by default exported function that writes to the console of the browser the name of the function.

The Content Of The App.vue
// inside script tag
import modules from './lib/**/*.js'

const [module0, module1] = modules

module0.default()
module1.default()

// example1
// example2


To import a vue file, you will need to add test, I pasted the config from the repository of the library, but it is possible to write the CD (again, through a rewriting of the field test).

You have to put the tag webpack, your question is not directly related to vue, and nothing to do with the gcd.
March 20th 20 at 11:25
Did the same as in your example.

Not working:
* ./actions/*.in js./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_mo
dules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=script&lang=js&
Put a non-working project on github and give the link. - Carmel_DuBuque commented on March 20th 20 at 11:28

Find more questions by tags Node.jsVue.js