-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.test.js
46 lines (46 loc) · 1.28 KB
/
webpack.config.test.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
const { resolve } = require('path');
module.exports = {
entry: {
main: ['core-js/stable', 'regenerator-runtime/runtime', './test/test.js']
},
module: {
rules: [{
test: /\.js$/i,
exclude: [/node_modules/i, /\.(min|umd)\.js$/i],
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
cacheDirectory: true
}
}
}, {
test: /\.(s[ac]ss|css)$/i,
use: [{
loader: 'style-loader',
options: { insert }
}, {
loader: 'css-loader',
options: { sourceMap: false }
}, {
loader: 'sass-loader',
options: { sourceMap: false }
}]
}]
},
output: {
path: resolve(__dirname, 'build', 'my-dizmo.test'),
environment: { arrowFunction: false },
filename: 'test.js'
},
mode: 'none'
};
function insert(style) {
const head = document.querySelector('head');
const links = head.querySelectorAll('link');
if (links.length > 0) {
head.insertBefore(style, links[links.length - 1]);
} else {
head.append(style);
}
}