-
Notifications
You must be signed in to change notification settings - Fork 556
Expand file tree
/
Copy pathwebpack.config.js
More file actions
101 lines (97 loc) · 2.55 KB
/
webpack.config.js
File metadata and controls
101 lines (97 loc) · 2.55 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
95
96
97
98
99
100
101
const { spawnSync } = require('child_process');
const fs = require('fs');
const tmp = require('tmp');
const path = require('path');
const pkg = require('./package.json');
const coreJsVersion = pkg.devDependencies['core-js'].replace(/^\^/, '');
/**
* 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,
allowedHosts: 'all',
server: {
type: 'https',
options: getDevCerts() || {}
},
static: {
directory: path.join(__dirname, 'support'),
publicPath: '/support'
}
},
stats: {
colors: true,
modules: true,
reasons: true
},
module: {
rules: [
{
// auth0-password-policies uses ES2020+ syntax (optional chaining) that
// must be transpiled for the IE 11 / ES2017 build target. Babel's
// .babelrc is file-relative and does not apply across package
// boundaries, so presets are passed explicitly here.
test: /\.js$/,
include: path.join(__dirname, 'node_modules', 'auth0-password-policies'),
loader: 'babel-loader',
options: {
presets: [['@babel/preset-env', { useBuiltIns: 'entry', corejs: coreJsVersion }]],
configFile: false,
babelrc: false
}
},
{
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'
}
}
]
}
]
}
};