This repository has been archived by the owner on Mar 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
71 lines (66 loc) · 1.69 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
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { resolve } = require('path')
const mode = process.env.NODE_ENV || 'development'
const dev = mode === 'development'
const sourceDir = resolve(__dirname, 'src')
const outputDir = resolve(__dirname, 'dist')
const entry = resolve(sourceDir, 'index.tsx')
const htmlTemplate = resolve(sourceDir, 'index.html')
const babelConfig = {
presets: [
'@babel/preset-env',
['@babel/preset-typescript', { jsxPragma: 'h' }]
],
plugins: [
'@babel/proposal-class-properties',
'@babel/proposal-object-rest-spread',
'@babel/plugin-transform-runtime',
[
'@babel/plugin-transform-react-jsx',
{
pragma: 'h',
pragmaFrag: 'Fragment'
}
]
]
}
module.exports = {
mode,
entry,
output: {
path: outputDir,
filename: 'bundle.js'
},
devtool: 'inline-source-map',
resolve: {
extensions: ['.ts', '.js', '.tsx', '.jsx'],
alias: {
react: 'preact/compat',
'react-dom/test-utils': 'preact/test-utils',
'react-dom': 'preact/compat'
}
},
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: 'babel-loader',
options: babelConfig
}
]
},
{
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader'
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: htmlTemplate
})
]
}