-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.ts
More file actions
105 lines (83 loc) · 1.82 KB
/
Copy pathwebpack.config.ts
File metadata and controls
105 lines (83 loc) · 1.82 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
102
103
104
105
import { CheckerPlugin } from 'awesome-typescript-loader';
import * as HtmlPlugin from 'html-webpack-plugin';
import * as path from 'path';
import { PORT } from 'src/config';
import * as webpack from 'webpack';
import { Configuration } from 'webpack-dev-server';
function Root(...paths: string[]) {
return path.join(__dirname, ...paths);
}
export const PublicPath = '/';
export const loaders: webpack.Rule[] = [
{
test: /.tsx?$/,
use: ['awesome-typescript-loader'],
exclude: ['node_modules'],
},
];
const Base: webpack.Configuration = {
mode: 'none',
context: __dirname,
resolve: {
extensions: ['.tsx', '.ts', '.js', '.jsx'],
modules: ['node_modules', 'src'],
},
externals: {},
devtool: 'source-map',
plugins: [
new CheckerPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
},
}),
],
stats: {
assets: true,
chunks: true,
},
};
export const Client: webpack.Configuration & { devServer: Configuration } = {
...Base,
target: 'web',
name: 'client',
entry: {
client: [
Root('src/client'),
],
},
output: {
path: Root('dist'),
publicPath: PublicPath,
filename: '[name].[hash:8].js',
chunkFilename: '[name].chunk.[hash:8].js',
},
module: {
rules: [
...loaders,
],
},
devServer: {
contentBase: Root('build'),
compress: true,
port: PORT,
hot: true,
inline: true,
historyApiFallback: true,
publicPath: '/',
host: '0.0.0.0',
disableHostCheck: true,
},
plugins: [
...Base.plugins || [],
new webpack.NoEmitOnErrorsPlugin(),
new webpack.HashedModuleIdsPlugin(),
new webpack.NamedChunksPlugin(chunk => chunk.name || 'faceless-chunk'),
new HtmlPlugin({
filename: 'index.html',
template: Root('src/index.html'),
}),
new webpack.HotModuleReplacementPlugin(),
],
};
export default [Client];