-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.mix.js
More file actions
94 lines (86 loc) · 2.85 KB
/
webpack.mix.js
File metadata and controls
94 lines (86 loc) · 2.85 KB
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
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your application. See https://github.com/JeffreyWay/laravel-mix.
|
*/
require('dotenv').config({ path: '.env.local' });
const mix = require('laravel-mix');
const glob = require('glob');
require('laravel-mix-stylelint');
require('laravel-mix-copy-watched');
/*
|--------------------------------------------------------------------------
| Configuration
|--------------------------------------------------------------------------
*/
mix
.sourceMaps()
.webpackConfig({
devtool: 'source-map',
})
.disableNotifications()
.options({
processCssUrls: false,
});
/*
|--------------------------------------------------------------------------
| Browsersync
|--------------------------------------------------------------------------
*/
mix.browserSync({
proxy: process.env.DRUPAL_BASE_URL,
files: [
'components/**/*.css',
'components/**/*.js',
'components/**/*.twig',
'templates/**/*.twig',
],
stream: true,
});
/*
|--------------------------------------------------------------------------
| SASS
|--------------------------------------------------------------------------
*/
mix.sass("src/scss/main.style.scss", "build/css/main.style.css");
for (const sourcePath of glob.sync("components/**/*.scss")) {
const destinationPath = sourcePath.replace(/\.scss$/, ".css");
mix.sass(sourcePath, destinationPath);
}
/*
|--------------------------------------------------------------------------
| JS
|--------------------------------------------------------------------------
*/
mix.js("src/js/main.script.js", "build/js/main.script.js");
for (const sourcePath of glob.sync("components/**/_*.js")) {
const destinationPath = sourcePath.replace(/\/_([^/]+\.js)$/, "/$1");
mix.js(sourcePath, destinationPath);
}
/*
|--------------------------------------------------------------------------
| Style Lint
|--------------------------------------------------------------------------
*/
mix.stylelint({
configFile: './.stylelintrc.json',
context: './src',
failOnError: false,
files: ['**/*.scss'],
quiet: false,
customSyntax: 'postcss-scss',
});
/*
|--------------------------------------------------------------------------
* IMAGES / ICONS / VIDEOS / FONTS
|--------------------------------------------------------------------------
*/
// * Directly copies the images, icons and fonts with no optimizations on the images
mix.copyDirectoryWatched('src/assets/images', 'build/assets/images');
mix.copyDirectoryWatched('src/assets/icons', 'build/assets/icons');
mix.copyDirectoryWatched('src/assets/videos', 'build/assets/videos');
mix.copyDirectoryWatched('src/assets/fonts/**/*', 'build/fonts');