-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
84 lines (72 loc) · 2.26 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
82
83
84
const path = require('path');
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
const FlowWebpackPlugin = require('flow-webpack-plugin');
const WebpackShellPlugin = require('webpack-shell-plugin');
const config = {
mode: 'development',
// Each entry will be compiled into dist/ directory
entry: {
polyfill: '@babel/polyfill',
server: path.resolve(path.join(__dirname, 'src/entry.js')),
test: path.resolve(path.join(__dirname, 'test/test.bootstrap.js'))
},
output: {
filename: '[name].bundle.js',
// Need to do this because path must be absolute
path: path.resolve(__dirname, 'dist')
},
devtool: 'inline-source-map',
watch: false,
target: 'node',
externals: [nodeExternals()],
node: {
__dirname: true
},
resolve: {
extensions: ['.js'],
modules: ['node_modules'],
alias: {
}
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: ['babel-loader', 'eslint-loader'], // eslint will only run on files imported by the project
},
// Not sure this is what we want....
// {
// test: /\.spec\.js$/,
// exclude: /node_modules/,
// use: [
// {
// // Run tests on compile
// loader: 'mocha-loader',
// },
// ]
// }
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
// Run Flow on Webpack Compile
new FlowWebpackPlugin({
failOnError: false,
failOnErrorWatch: false,
reportingSeverity: 'error'
}),
// TODO: Run tests only once on start-dev, rebuild and restart server on changes
// tests can be run again by the developer before commits, or on new npm run
// IDEA: build once with webpack, start server with nodeman, start webpack watch?
new WebpackShellPlugin({
// whoa, why is this different than mocha.opts?
// q: what is the difference between doing this and running spec individually?
// does this still pick up mocha.opts? does this add to it?
// how is output of this when exceptions thrown vs if we run the test files indidually? (mocha.opts)
onBuildExit: 'mocha --env.unit_test ./dist/test.bundle.js'
}),
]
};
module.exports = config;