-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.mix.js
130 lines (115 loc) · 4.46 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
const mix = require('laravel-mix');
const fs = require('fs');
const path = require('path');
const package = JSON.parse(fs.readFileSync('./package.json'));
const ESLintPlugin = require('eslint-webpack-plugin');
const replace = require('replace-in-file');
/*
|--------------------------------------------------------------------------
| 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 your application, as well as bundling up your JS files.
|
*/
// Copy & Rename Blade Files and Replace date in Footer, necessary to do outside of mix.copy and webpack plugins due to
// file changes causing infinite loops during make watch.
fs.copyFileSync('node_modules/@waynestate/wsuheader/dist/header.html', 'resources/views/components/header.blade.php', fs.constants.COPYFILE_FICLONE);
fs.copyFileSync('node_modules/@waynestate/wsufooter/dist/footer.html', 'resources/views/components/footer.blade.php', fs.constants.COPYFILE_FICLONE);
fs.copyFileSync('vendor/waynestate/error-404/dist/404.php', 'resources/views/errors/404.blade.php', fs.constants.COPYFILE_FICLONE);
fs.copyFileSync('vendor/waynestate/error-403/dist/403.php', 'resources/views/errors/403.blade.php', fs.constants.COPYFILE_FICLONE);
fs.copyFileSync('vendor/waynestate/error-429/dist/429.php', 'resources/views/errors/429.blade.php', fs.constants.COPYFILE_FICLONE);
fs.copyFileSync('vendor/waynestate/error-500/dist/500.php', 'resources/views/errors/500.blade.php', fs.constants.COPYFILE_FICLONE);
fs.copyFileSync('vendor/waynestate/error-500/dist/500.php', 'resources/views/errors/500.blade.php', fs.constants.COPYFILE_FICLONE);
if (!mix.inProduction()) {
if(!fs.existsSync('.git/hooks')) {
fs.mkdir('.git/hooks', (err) => {
if (err) {
return console.error(err);
}
console.log('.git/hooks directory created.');
});
}
fs.copyFileSync('hooks/pre-commit', '.git/hooks/pre-commit', fs.constants.COPYFILE_FICLONE);
}
replace.sync({
files: 'resources/views/components/footer.blade.php',
from: /2\d{3}/g,
to: "{{ date('Y') }}",
});
// Error Files
mix.copy([
'vendor/waynestate/error-404/dist/404.css',
'vendor/waynestate/error-404/dist/404.css.map',
'vendor/waynestate/error-403/dist/403.css',
'vendor/waynestate/error-403/dist/403.css.map',
'vendor/waynestate/error-429/dist/429.css',
'vendor/waynestate/error-429/dist/429.css.map',
'vendor/waynestate/error-500/dist/500.css',
'vendor/waynestate/error-500/dist/500.css.map'
], 'public/_resources/css')
// Header files
.copy([
'vendor/waynestate/error-404/dist/404.png',
'vendor/waynestate/error-403/dist/403.png',
'vendor/waynestate/error-429/dist/429.png',
'vendor/waynestate/error-500/dist/500.png'
], 'public/_resources/images')
// Fonts
.copy([
'resources/fonts/**/*'
], 'public/_resources/fonts')
// Images
.copyDirectory([
'resources/images'
], 'public/_resources/images');
// Compile assets and setup browersync
mix.js('resources/js/main.js', 'public/_resources/js')
.sass('resources/scss/main.scss', 'public/_resources/css/main.css')
.sourceMaps()
.options({
processCssUrls: false,
postCss: [
require('tailwindcss'),
require('autoprefixer')
]
})
.browserSync({
proxy: 'https://' + package.name + '.wayne.local',
open: false,
files: [
'app/**/*.php',
'resources/views/**/*.php',
'public/_resources/js/main.js',
'public/_resources/css/main.css',
'tailwind.config.js'
],
watchOptions: {
usePolling: true,
interval: 500
}
});
// Create the _static symlink
fs.symlink(
path.resolve('./storage/app/public'),
path.resolve('./public/_static'),
function (err) { err != null && err.errno != -17 ? console.log(err) : console.log("./storage/app/public symlinked to ./public/_static/ created."); }
);
config = {
plugins: [
new ESLintPlugin({
exclude: [
'node_modules'
],
}),
],
devtool: 'source-map'
};
if (mix.inProduction()) {
// Version the CSS for cache busting
mix.version();
}
// Override webpack configuration
mix.webpackConfig(config);