-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
93 lines (92 loc) · 2.16 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
92
93
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const HappyPack = require('happypack');
const webpack = require('webpack');
const isProd = process.env.NODE_ENV !== 'development';
const devtool = isProd ? {} : {devtool: 'source-map'};
const chunk = isProd ? {
optimization: {
splitChunks: {
chunks: 'all',
minChunks: 3,
name: 'common',
},
minimize: true,
},
} : {};
module.exports = {
mode: 'development',
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
entry: path.resolve(__dirname, './demo/entry.tsx'),
output: {
filename: 'js/build-[hash].js',
path: path.resolve(__dirname, './docs'),
publicPath: isProd ? './' : '/',
chunkFilename: 'js/[name].js',
},
module: {
rules: [
{
test: /\.(tsx|ts)$/,
use: ['happypack/loader?id=ts'],
include: [
path.resolve('demo'),
path.resolve('src'),
],
exclude: [/__tests__/],
},
{
test: /\.(css)$/,
use: ['happypack/loader?id=css'],
include: [
path.resolve('demo'),
path.resolve('src'),
path.resolve(__dirname, 'node_modules/yoshino'),
],
},
]
},
...chunk,
...devtool,
plugins: [
new HtmlWebpackPlugin({
template: path.resolve('./demo/index.html'),
}),
new ForkTsCheckerWebpackPlugin(),
new HappyPack({
id: 'ts',
loaders: [
{
loader: 'ts-loader',
options: {
happyPackMode: true,
transpileOnly: true,
},
},
{
loader: 'ui-component-loader',
options: {
lib: 'yoshino',
libDir: 'lib',
style: 'style/index.js'
}
}
]
}),
new HappyPack({
id: 'css',
loaders: ['css-hot-loader', 'style-loader', 'css-loader']
}),
new webpack.HotModuleReplacementPlugin(),
],
devServer: {
historyApiFallback: true,
contentBase: path.join(__dirname, "./docs"),
compress: false,
port: 9001,
hot: true,
},
};