-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
102 lines (101 loc) · 2.42 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
94
95
96
97
98
99
100
101
102
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');
module.exports = {
mode: 'development',
resolve: {
extensions: ['.ts', '.tsx', '.js'],
alias: {
'@docs': path.resolve(__dirname, './docs')
}
},
entry: path.resolve('./docs/entry.tsx'),
output: {
filename: 'js/build.js',
path: path.resolve(__dirname, './build'),
publicPath: '/',
chunkFilename: 'js/[name].js',
},
module: {
rules: [
{
test: /\.(tsx|ts)$/,
use: ['happypack/loader?id=ts'],
include: [path.resolve('components'), path.resolve('docs')],
exclude: [/__tests__/],
},
{
test: /\.(css|less)$/,
use: ['happypack/loader?id=css'],
include: [
path.resolve('scripts'),
path.resolve('docs'),
path.resolve('node_modules/prismjs/themes/'),
path.resolve('node_modules/yoshino/'),
],
},
{
test: /\.(png|jpe?g|gif)$/,
use: ['file-loader'],
},
{
test: /\.(woff2?|eot|ttf|otf|svg)(\?.*)?$/,
use: ['url-loader'],
},
{
test: /\.md$/,
use: ['raw-loader'],
},
]
},
devtool: 'source-map',
optimization: {
splitChunks: {
chunks: 'all',
minChunks: 3,
name: 'common',
},
minimize: true,
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve('./docs/index.html'),
favicon: path.resolve('./docs/favicon.ico'),
}),
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', 'postcss-loader', 'less-loader']
}),
new webpack.HotModuleReplacementPlugin(),
],
devServer: {
historyApiFallback: true,
contentBase: path.join(__dirname, "build"),
compress: false,
port: 9000,
hot: true,
},
};