forked from getkirby/getkirby.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.mix.js
114 lines (95 loc) · 2.74 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
/* eslint-env node */
/* eslint-disable no-console, no-sync, array-bracket-newline, no-process-env */
const autoprefixer = require("autoprefixer");
const calc = require("postcss-calc");
const extend = require("extend");
const fs = require("fs");
const glob = require("glob");
const mix = require("laravel-mix");
const path = require("path");
/* -------------------------------------------------------------------------- */
const ENV = process.env.NODE_ENV;
/* Load user config if exists */
const defaultConfig = JSON.parse(fs.readFileSync("./config.default.json"));
let config = {};
if (fs.existsSync(path.resolve(__dirname, "./config.json"))) {
config = extend(defaultConfig, JSON.parse(fs.readFileSync("./config.json"))); // eslint-disable-line global-require
} else {
config = defaultConfig;
}
/**
* 1. Make $ENV variable globally available in SASS.
*/
const sassSettings = {
data: `$ENV: ${ENV};`, /* 1 */
precision: 10,
};
/**
* 1. Deactivate integrated autoprefixer, because configuration is
* hardcoded (May 28th, 2018) and cannot be changed via
* configuration.
*/
mix.options({
autoprefixer: false, /* 1 */
postCss: [
calc({ precision: 10 }),
autoprefixer({
browsers: [
"last 2 versions",
"not IE < 11",
"not IE_mob <= 11",
"not BB <= 10",
],
grid: false,
})
]
});
/* -------------------------------------------------------------------------- */
mix.js("src/js/index.js", "js");
mix.js("src/js/polyfills/respimage.js", "js/polyfills");
mix.js("src/js/polyfills/promise.js", "js/polyfills");
/* Search for template-specific JavaScript files */
const templateJS = glob.sync("./src/js/templates/*.js");
for (let i = 0, l = templateJS.length; i < l; i++) {
mix.js(templateJS[i], "js/templates");
}
mix.sass("src/scss/index.scss", "css", sassSettings);
/* Search for template-specific CSS files */
const templateCSS = glob.sync("./src/scss/templates/*.scss");
for (let i = 0, l = templateCSS.length; i < l; i++) {
mix.sass(templateCSS[i], "css/templates", sassSettings);
}
/* -------------------------------------------------------------------------- */
mix.browserSync({
proxy: {
target: config.host,
},
files: [
"www/assets/css/*.css",
"www/assets/css/templates/*.css",
"www/assets/js/*.js",
"site/snippets/**/*.php",
"site/templates/**/*.php",
"www/content/**/*",
],
open: false,
ghostMode: false,
});
mix.sourceMaps();
mix.disableNotifications();
mix.setPublicPath("www/assets");
mix.setResourceRoot("/assets/");
mix.webpackConfig({
output: {
publicPath: "/assets/",
chunkFilename: "js/bundle-[name].js?id=[chunkhash]",
},
plugins: [
],
stats: {
assets: false,
chunks: false,
hash: false,
},
});
mix.version();