-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.mix.js
137 lines (126 loc) · 3.78 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
131
132
133
134
135
136
137
require('dotenv').config();
const mix = require('laravel-mix');
const { exec } = require('child_process');
const path = require('path');
const webpack = require('webpack');
require('laravel-mix-polyfill');
mix.extend('ziggy', new class {
register(config = {})
{
this.watch = config.watch ?? ['routes/**/*.php'];
this.path = config.path ?? '';
this.enabled = config.enabled ?? !Mix.inProduction();
}
boot()
{
if ( !this.enabled )
{
return;
}
const command = () => exec(`${process.env.APP_PHP_PATH} artisan ziggy:generate ${this.path}`, (error, stdout, stderr) => {
if( error )
{
console.log('error: ', error);
}
if( stdout )
{
console.log(stdout);
}
if( stderr )
{
console.log('stderr: ', stderr);
}
});
command();
if( Mix.isWatching() && this.watch )
{
((require('chokidar')).watch(this.watch)).on('change', (path) => {
console.log(`${path} changed...`);
command();
});
};
}
}());
mix
.ziggy({
enabled: true,
path: 'resources/js/ziggy.js'
})
.webpackConfig({
stats: {
children: false
},
resolve: {
alias: {
ziggy: path.resolve('vendor/tightenco/ziggy/dist'),
},
},
// module: {
// rules: [{
// test: /\.jsx?$/,
// exclude: /(bower_components)/,
// use: [
// {
// loader: 'babel-loader',
// // options: (Config || mix.config).babel(),
// options: {
// presets: [
// '@babel/preset-env'
// ],
// plugins: [
// '@babel/plugin-syntax-throw-expressions',
// '@babel/plugin-transform-runtime',
// ]
// }
// },
// ],
// }],
// }
});
mix
.alias({
// ziggy: path.resolve('vendor/tightenco/ziggy/dist/vue'), // or 'vendor/tightenco/ziggy/dist/vue' if you're using the Vue plugin
ziggy: path.resolve('vendor/tightenco/ziggy/dist'), // or 'vendor/tightenco/ziggy/dist/vue' if you're using the Vue plugin
})
.options({
processCssUrls: false,
runtimeChunkPath: 'storage',
terser: {
extractComments: false,
},
autoprefixer: {
enabled: true,
options: {
remove: false
}
},
postCss:[
require('autoprefixer')(),
],
}).disableSuccessNotifications();
mix
.js('resources/js/app.js', 'public/storage/js/app.min.js')
.polyfill({
enabled: true,
useBuiltIns: 'usage',
entryPoints: 'all',
corejs: 3,
targets: '> 0.25%, not dead, IE >= 8',
debug: false,
})
.vue()
.sass('resources/sass/error.scss', 'public/storage/css/error.min.css')
.sass('resources/sass/app.scss', 'public/storage/css/app.min.css')
.version();
if( !mix.inProduction() && process.env.MIX_USE_BROWSERSYNC == 'true' )
{
// Обновление браузера после внесенных изменений
mix
.browserSync({
proxy: process.env.APP_DOMAIN,
https: {
key: process.env.MIX_SSL_KEY,
cert: process.env.MIX_SSL_CERT
}
});
}