-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ts
76 lines (73 loc) · 2.35 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
import * as webpack from 'webpack'
import * as path from 'path'
import * as HtmlWebpackPlugin from 'html-webpack-plugin'
import { GenerateSW } from 'workbox-webpack-plugin'
const config: webpack.Configuration = {
mode: 'development',
entry: {
app: ['./src/App.tsx', 'webpack-hot-middleware/client'],
vendor: ['react', 'react-dom'],
},
output: {
path: path.resolve(__dirname, './frontEnd'),
filename: 'js/[name].bundle.js',
devtoolModuleFilenameTemplate: 'file:///[absolute-resource-path]', // for vscode debugger
},
devtool: 'source-map',
resolve: {
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
loader: 'awesome-typescript-loader',
query: {
configFileName: './src/tsconfig.frontend.json',
},
},
{
enforce: 'pre',
test: /\.js$/,
exclude: /node_modules/,
loader: 'source-map-loader',
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/',
},
},
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, '../src', 'index.html'),
}),
new webpack.HotModuleReplacementPlugin(),
new GenerateSW({
clientsClaim: true,
skipWaiting: true,
}),
],
// When importing a module whose path matches one of the following, just
// assume a corresponding global variable exists (CDN) and use that instead.
// This is important because it allows us to avoid bundling all of our
// dependencies, which allows browsers to cache those libraries between builds.
externals: {
react: 'React',
'react-dom': 'ReactDOM',
},
}
export default config