-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.mix.js
52 lines (45 loc) · 1.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
const { join, resolve } = require('path')
const { copySync, removeSync } = require('fs-extra')
const mix = require('laravel-mix')
require('laravel-mix-versionhash')
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
mix
.js('resources/js/app.js', 'public/dist/js').vue({
extractStyles: true
})
.sass('resources/sass/app.scss', 'public/dist/css')
.disableNotifications()
if (mix.inProduction()) {
mix
// .extract() // Disabled until resolved: https://github.com/JeffreyWay/laravel-mix/issues/1889
// .version() // Use `laravel-mix-versionhash` for the generating correct Laravel Mix manifest file.
.versionHash()
} else {
mix.sourceMaps()
}
mix.webpackConfig({
plugins: [
// new BundleAnalyzerPlugin()
],
resolve: {
extensions: ['.js', '.json', '.vue'],
alias: {
'~': join(__dirname, './resources/js')
}
},
output: {
chunkFilename: 'dist/js/[chunkhash].js',
path: resolve(__dirname, mix.inProduction() ? './public/build' : './public')
}
})
mix.then(() => {
if (mix.inProduction()) {
process.nextTick(() => publishAseets())
}
})
function publishAseets () {
const publicDir = resolve(__dirname, './public')
removeSync(join(publicDir, 'dist'))
copySync(join(publicDir, 'build', 'dist'), join(publicDir, 'dist'))
removeSync(join(publicDir, 'build'))
}