-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.mix.js
More file actions
78 lines (67 loc) · 1.62 KB
/
Copy pathwebpack.mix.js
File metadata and controls
78 lines (67 loc) · 1.62 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
const mix = require('laravel-mix');
const path = require('path');
const styleLintPlugin = require('stylelint-webpack-plugin');
const autoprefixer = require('autoprefixer');
const cssMqpacker = require('css-mqpacker');
const postcssCustomMedia = require('postcss-custom-media');
const cpx = require('cpx');
require('laravel-mix-eslint');
require('dotenv').config();
const sourcesPath = path.resolve('src');
const outputPath = mix.inProduction() ? 'dist' : `public/wp-content/themes/${process.env.PROJECT_NAME}`;
const copyFiles = `${sourcesPath}/**/*.{html,php,css,png,jpg,gif,svg,woff,woff2,eot,ttf,txt,md,pdf,webm,mp4,ico}`;
mix.autoload({
jquery: ['$', 'jQuery']
});
if (process.env.NODE_ENV === 'watch') {
cpx.watch(copyFiles, outputPath);
} else {
cpx.copy(copyFiles, outputPath);
}
mix
.setPublicPath(outputPath)
.sass(`${sourcesPath}/scss/all.scss`, `${outputPath}/css`)
.js(`${sourcesPath}/js/main.js`, `${outputPath}/js`)
.eslint({
fix: false,
cache: false
});
mix.webpackConfig({
plugins: [
new styleLintPlugin({
configFile: path.resolve('.stylelintrc'),
files: ['**/*.scss'],
syntax: 'scss'
})
]
});
mix.options({
cache: true,
keepalive: true,
processCssUrls: false,
postCss: [
autoprefixer,
postcssCustomMedia,
cssMqpacker({
sort: true
})
],
clearConsole: true
});
if (mix.inProduction()) {
mix.options({
cache: false,
postCss: [
require('csswring')({
removeAllComments: false
})
]
});
} else {
mix
.sourceMaps()
.webpackConfig({
devtool: 'inline-source-map'
});
}
mix.disableNotifications();