Answer the question
In order to leave comments, you need to log in
VueJS: Import global?
How to attach global imports to vue cli?
https://github.com/terpiljenya/import-glob#readme
I couldn't set up vue.config.js correctly
Answer the question
In order to leave comments, you need to log in
Good afternoon!
Content vue.config.js
:
module.exports = {
configureWebpack: {
module: {
rules: [{
test: /\.js/,
loader: 'import-glob'
},
{
test: /\.scss/,
loader: 'import-glob'
}
]
}
}
}
src/
├── App.vue
...
│
├── lib
│ ├── example
│ │ └── example.js # example2
│ └── example.js # example1
└── main.js
// inside script tag
import modules from './lib/**/*.js'
const [module0, module1] = modules
module0.default()
module1.default()
// example1
// example2
I did the same as in your example.
Does not work:
* ./actions/*.js in ./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&
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question