-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
91 lines (90 loc) · 2.49 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
85
86
87
88
89
90
91
const path = require('path')
var HappyPack = require('happypack')
const nodeExternals = require('webpack-node-externals')
const FilterWarningsPlugin = require('webpack-filter-warnings-plugin')
const tsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')
var ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const mode =
process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'prod'
? 'production'
: 'development'
const isProd = mode === 'production'
const webpack = require('webpack')
// Common plugins
let plugins = [
new webpack.NamedModulesPlugin(),
new FilterWarningsPlugin({
exclude: [
/Critical dependency: the request of a dependency is an expression/,
/require.extensions is not supported by webpack. Use a loader instead./
]
}),
new HappyPack({
id: 'ts',
threads: 4,
loaders: [
{
path: 'ts-loader',
query: { happyPackMode: true }
}
]
}),
new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true })
]
if (!mode) {
plugins.push(new webpack.HotModuleReplacementPlugin())
}
module.exports = {
node: {
__dirname: true
},
entry: './src/App.ts',
devtool: false,
mode: mode,
target: 'node',
externals: [nodeExternals()],
resolve: {
alias: {
handlebars: 'handlebars/dist/handlebars.js',
'@hapi/vision': '@hapi/vision/lib/index.js'
},
extensions: [
'.webpack-loader.js',
'.web-loader.js',
'.loader.js',
'.js',
'.jsx',
'.ts'
],
modules: [path.resolve('./src'), 'node_modules'],
plugins: [new tsconfigPathsPlugin()]
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].bundle.js',
libraryTarget: 'commonjs2'
},
target: 'node',
plugins: plugins,
context: __dirname,
module: {
rules: [
{
test: /\.ts(x?)$/,
include: [path.resolve(__dirname, 'src')],
exclude: /node_modules/,
use: [
{
loader: 'happypack/loader?id=ts'
}
]
},
{
enforce: 'pre',
test: /\.ts$/,
exclude: /node_modules/,
use: 'tslint-loader'
}
]
}
}