-
Notifications
You must be signed in to change notification settings - Fork 556
/
webpack.config.js
81 lines (77 loc) · 1.78 KB
/
webpack.config.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
const { spawnSync } = require('child_process');
const fs = require('fs');
const tmp = require('tmp');
const path = require('path');
/**
* This is a helper function to generate valid certs using mkcert.
* If mkcert is not installed it will return false.
*/
function getDevCerts() {
let result = false;
const tmpDir = tmp.dirSync({ unsafeCleanup: true, prefix: 'lock-dev-' });
try {
spawnSync('mkcert', ['localhost'], { cwd: tmpDir.name });
result = {
key: fs.readFileSync(path.join(tmpDir.name, 'localhost-key.pem')),
cert: fs.readFileSync(path.join(tmpDir.name, 'localhost.pem'))
};
} catch (err) {}
tmpDir.removeCallback();
return result;
}
module.exports = {
entry: './src/browser.js',
mode: 'development',
target: 'browserslist',
output: {
path: path.join(__dirname, '../build'),
filename: 'lock.js'
},
resolve: {
extensions: ['.webpack.js', '.web.js', '.js', '.jsx', '.styl']
},
devtool: 'source-map',
progress: true,
watch: true,
watchOptions: {
aggregateTimeout: 500,
poll: true
},
devServer: {
hot: true,
port: 3000,
https: getDevCerts() || true,
static: {
directory: path.join(__dirname, 'support'),
publicPath: '/support'
}
},
stats: {
colors: true,
modules: true,
reasons: true
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: path.join(__dirname, 'node_modules')
},
{
test: /\.styl$/,
use: [
'css-loader',
'stylus-loader',
{
loader: 'stylus-loader',
options: {
paths: ['node_modules/bootstrap-stylus/stylus'],
preferPathResolver: 'webpack'
}
}
]
}
]
}
};