This question already has an answer here:
- Is it possible to import modules from all files in a directory, using a wildcard? 10 answers
So I am trying to create a vue instance that needs other components from folder "views/"
Here is the file structure:
- Project
- build/
- config/
- node_modules/
- src/
- views/
- components/
- App.vue
If I do this in App.vue, the server will run with no error:
import Navbar from 'layouts/Navbar'
import Topbar from 'layouts/Topbar'
import AppMain from 'layouts/AppMain'
But if I try this instead:
import { AppMain, Navbar, Topbar } from 'layouts/'
The server won't run and will return:
This dependency was not found:
* views/ in ./src/router/index.js
Here is the webpack.base.config.js
function resolve (dir) {
return path.join(__dirname, '..', dir)
}
module.exports = {
entry: {
app: './src/main.js'
},
output: {
path: config.build.assetsRoot,
filename: '[name].js',
publicPath: process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
},
resolve: {
extensions: ['.js', '.vue', '.json', '.scss'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src'),
'layouts': resolve('src/layouts'),
'views': resolve('src/views'),
'components': resolve('src/components'),
'variables': path.resolve(__dirname, '../src/assets/common/variables.scss'),
},
},
I really have no idea what's wrong, plz help, thx