Answer the question
In order to leave comments, you need to log in
How to import js file with laravel-mix without using relative paths?
Welcome all!
Now Laravel uses webpack to build js (like css). Laravel does not use webpack directly, but through laravel-mix. On the one hand, this helps, and on the other hand, it imposes its own limitations and difficulties.
I connect another inside one js file using import:
import Vuetable from 'vuetable-2/src/components/Vuetable' // Путь относительно node_modules
import VuetablePagination from 'vuetable-2/src/components/VuetablePagination'
import CssConfig from '../../VuetableCssConfig' // Путь относительно текущего файла
import CssConfig from 'components/VuetableCssConfig'
...
let path = require('path');
mix.webpackConfig({
resolve: {
modules: [
path.resolve('./resources/assets/js'),
path.resolve('./node_modules')
]
}
});
This dependency was not found:
* components/VuetableCssConfig in ./~/babel-loader/lib?{"cacheDirectory":true,"presets":}!. /~/vue-loader/lib/selector.js?type=script&index=0!./resources/assets/js/components/earnings/EarningsTable.vue
To install it, you can run: npm install --save components/VuetableCssConfig
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question