-
Notifications
You must be signed in to change notification settings - Fork 22
/
webpack.config.ts
95 lines (91 loc) · 2.94 KB
/
webpack.config.ts
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
/* eslint-disable spaced-comment */
/// <reference types="@types/node" />
/// <reference types="@types/webpack-dev-server" />
import HtmlWebpackPlugin from 'html-webpack-plugin';
import { join } from 'path';
import { ProvidePlugin, Configuration } from 'webpack';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
const config: Configuration = {
mode: 'development',
entry: './src/ui/index.tsx',
output: {
filename: 'bundle.js',
path: join(__dirname, '/../dist')
},
devServer: {
port: 3000,
compress: true,
historyApiFallback: true
},
devtool: 'source-map',
plugins: [
new ForkTsCheckerWebpackPlugin(),
new HtmlWebpackPlugin({
template: './src/ui/app.ejs',
meta: {
viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'
}
}),
new ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
// http: 'stream-http',
// https: 'https-browserify',
// os: 'os-browserify/browser',
process: 'process/browser'
// vm: 'vm-browserify'
})
],
module: {
rules: [
{
test: /\.(css)$/,
use: [
{
loader: 'style-loader' // creates style nodes from JS strings
},
{
loader: 'css-loader' // translates CSS into CommonJS
}
]
},
{
test: /\.(png|jpg|gif|svg)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 8192
}
}
]
},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{ enforce: 'pre', test: /\.js\.map$/, loader: 'source-map-loader' },
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
configFile: 'tsconfig.build.json',
projectReferences: true,
transpileOnly: true
}
}
]
},
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: ['.ts', '.tsx', '.js', '.json'],
fallback: {
assert: require.resolve('assert'),
crypto: require.resolve('crypto-browserify'),
fs: false,
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
os: require.resolve('os-browserify/browser'),
process: require.resolve('process/browser'),
stream: require.resolve('stream-browserify'),
vm: require.resolve('vm-browserify')
}
}
};
export default config;