-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.mix.js
158 lines (138 loc) · 5.21 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
const { EnvironmentPlugin, IgnorePlugin } = require('webpack');
const mix = require('laravel-mix');
const glob = require('glob');
const path = require('path');
/*
|--------------------------------------------------------------------------
| Configure mix
|--------------------------------------------------------------------------
*/
mix.options({
resourceRoot: process.env.ASSET_URL || undefined,
processCssUrls: false,
postCss: [require('autoprefixer')]
});
/*
|--------------------------------------------------------------------------
| Configure Webpack
|--------------------------------------------------------------------------
*/
mix.webpackConfig({
output: {
publicPath: process.env.ASSET_URL || undefined,
libraryTarget: 'umd'
},
plugins: [
new IgnorePlugin({
checkResource(resource, context) {
return [
path.join(__dirname, 'resources/assets/vendor/libs/@form-validation')
// Add more paths to ignore as needed
].some(pathToIgnore => resource.startsWith(pathToIgnore));
}
}),
new EnvironmentPlugin({
// Application's public url
BASE_URL: process.env.ASSET_URL ? `${process.env.ASSET_URL}/` : '/'
})
],
module: {
rules: [
{
test: /\.es6$|\.js$/,
include: [
path.join(__dirname, 'node_modules/bootstrap/'),
path.join(__dirname, 'node_modules/popper.js/'),
path.join(__dirname, 'node_modules/shepherd.js/')
],
loader: 'babel-loader',
options: {
presets: [['@babel/preset-env', { targets: 'last 2 versions, ie >= 10' }]],
plugins: [
'@babel/plugin-transform-destructuring',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-template-literals'
],
babelrc: false
}
}
]
},
externals: {
jquery: 'jQuery',
moment: 'moment',
jsdom: 'jsdom',
velocity: 'Velocity',
hammer: 'Hammer',
pace: '"pace-progress"',
chartist: 'Chartist',
'popper.js': 'Popper',
// blueimp-gallery plugin
'./blueimp-helper': 'jQuery',
'./blueimp-gallery': 'blueimpGallery',
'./blueimp-gallery-video': 'blueimpGallery'
}
});
/*
|--------------------------------------------------------------------------
| Vendor assets
|--------------------------------------------------------------------------
*/
function mixAssetsDir(query, cb) {
(glob.sync('resources/assets/' + query) || []).forEach(f => {
f = f.replace(/[\\\/]+/g, '/');
cb(f, f.replace('resources/assets/', 'public/assets/'));
});
}
/*
|--------------------------------------------------------------------------
| Configure sass
|--------------------------------------------------------------------------
*/
const sassOptions = {
precision: 5
};
// Core stylesheets
mixAssetsDir('vendor/scss/**/!(_)*.scss', (src, dest) =>
mix.sass(src, dest.replace(/(\\|\/)scss(\\|\/)/, '$1css$2').replace(/\.scss$/, '.css'), { sassOptions })
);
// Core JavaScripts
mixAssetsDir('vendor/js/**/*.js', (src, dest) => mix.js(src, dest));
// Libs
mixAssetsDir('vendor/libs/**/*.js', (src, dest) => mix.js(src, dest));
mixAssetsDir('vendor/libs/**/!(_)*.scss', (src, dest) =>
mix.sass(src, dest.replace(/\.scss$/, '.css'), { sassOptions })
);
mixAssetsDir('vendor/libs/**/*.{png,jpg,jpeg,gif}', (src, dest) => mix.copy(src, dest));
// Copy task for form validation plugin as premium plugin don't have npm package
mixAssetsDir('vendor/libs/@form-validation/umd', (src, dest) => mix.copyDirectory(src, dest));
// Fonts
mixAssetsDir('vendor/fonts/*/*', (src, dest) => mix.copy(src, dest));
mixAssetsDir('vendor/fonts/!(_)*.scss', (src, dest) =>
mix.sass(src, dest.replace(/(\\|\/)scss(\\|\/)/, '$1css$2').replace(/\.scss$/, '.css'), { sassOptions })
);
/*
|--------------------------------------------------------------------------
| Application assets
|--------------------------------------------------------------------------
*/
mixAssetsDir('js/**/*.js', (src, dest) => mix.scripts(src, dest));
mixAssetsDir('css/**/*.css', (src, dest) => mix.copy(src, dest));
// laravel working crud app related js
mix.js('resources/js/laravel-user-management.js', 'public/js/');
mix.copy('node_modules/flag-icons/flags/1x1/*', 'public/assets/vendor/fonts/flags/1x1');
mix.copy('node_modules/flag-icons/flags/4x3/*', 'public/assets/vendor/fonts/flags/4x3');
mix.copy('node_modules/@fortawesome/fontawesome-free/webfonts/*', 'public/assets/vendor/fonts/fontawesome');
mix.copy('node_modules/katex/dist/fonts/*', 'public/assets/vendor/libs/quill/fonts');
mix.version();
/*
|--------------------------------------------------------------------------
| Browsersync Reloading
|--------------------------------------------------------------------------
|
| BrowserSync can automatically monitor your files for changes, and inject your changes into the browser without requiring a manual refresh.
| You may enable support for this by calling the mix.browserSync() method:
| Make Sure to run `php artisan serve` and `yarn watch` command to run Browser Sync functionality
| Refer official documentation for more information: https://laravel.com/docs/10.x/mix#browsersync-reloading
*/
mix.browserSync('http://127.0.0.1:8000/');