-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.mix.js
94 lines (89 loc) · 2.33 KB
/
webpack.mix.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const mix = require('laravel-mix');
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin'); //installed via npm
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
function resolve(dir) {
return path.join(__dirname, dir);
}
if (mix.config.hmr) {
mix.setResourceRoot('//localhost:8080/');
}
mix
// .setPublicPath('public/dist')
.js('resources/js/main.js', 'public/js')
// .js('resources/js/main.js', 'public/dist/js')
// .copy('public/dist/hot', 'public/hot')
// .sass('resources/sass/app.scss', 'public/dist/css')
// .extract();
// .options({
// vue: {
// transformAssetUrls: {
// 'img': 'src',
// 'image': 'xlink:href',
// 'b-img': 'src',
// 'b-img-lazy': ['src', 'blank-src'],
// 'b-card': 'img-src',
// 'b-card-img': 'img-src',
// 'b-carousel-slide': 'img-src',
// 'b-embed': 'src'
// }
// }
// })
.webpackConfig({
stats: 'minimal',
output: {
// publicPath: 'http://localhost:8080/'
// filename: 'js/[name].js',
chunkFilename: 'js/[id].js',
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('resources/js'),
'static': resolve('resources/static')
}
},
devServer: {
proxy: {
'/api': 'http://localhost:8000'
},
quiet: true
},
plugins: [
new CleanWebpackPlugin(
[
'images',
'fonts',
'js'
], {
root: resolve('public')
}
),
]
});
// eslint-disable-next-line no-undef
Mix.listen('configReady', webpackConfig => {
// eslint-disable-next-line no-undef
if (Mix.isUsing('hmr')) {
// Remove leading '/' from entry keys
webpackConfig.entry = Object.keys(webpackConfig.entry).reduce((entries, entry) => {
entries[entry.replace(/^\//, '')] = webpackConfig.entry[entry];
return entries;
}, {});
// Remove leading '/' from ExtractTextPlugin instances
webpackConfig.plugins.forEach(plugin => {
if (plugin.constructor.name === 'ExtractTextPlugin') {
plugin.filename = plugin.filename.replace(/^\//, '');
}
});
}
});