-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts
94 lines (85 loc) · 2.38 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
import webpack from 'webpack'
import path from 'path'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import ExtractCssChunks from 'extract-css-chunks-webpack-plugin'
// import MiniCSSExtractPlugin from 'mini-css-extract-plugin'
// import ExtractTextPlugin from 'extract-text-webpack-plugin'
const config: webpack.Configuration = {
entry: {
app: ['webpack-hot-middleware/client?reload=true', './client/app/app.tsx']
// app: './client/app/app.tsx'
},
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
filename: 'bundle.js',
chunkFilename: '[id].chunk.js'
},
// Enable sourcemaps for debugging webpack's output.
devtool: 'cheap-module-source-map',
mode: 'development',
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: ['.ts', '.tsx', '.js', '.json'],
alias: {
app: 'client/app'
}
},
module: {
rules: [
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
{
test: /\.tsx?$/,
// provide array of loaders
use: [
{
loader: 'babel-loader',
options: {
babelrc: false,
cacheDirectory: true,
plugins: ['react-hot-loader/babel']
}
},
'awesome-typescript-loader'
],
exclude: /node_modules/
},
{
test: /\.(sa|c)ss$/,
use: [
// MiniCSSExtractPlugin.loader,
ExtractCssChunks.loader,
{
loader: 'css-loader',
options: {
sourceMap: true,
importLoaders: 1
}
},
'sass-loader'
]
},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{ enforce: 'pre', test: /\.js$/, loader: 'source-map-loader' }
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
new HtmlWebpackPlugin({
template: './client/public/index.html',
inject: 'body'
}),
// new ExtractTextPlugin({
new ExtractCssChunks({
filename: 'css/style.css'
})
],
devServer: {
hot: true,
contentBase: './client/public',
historyApiFallback: true,
stats: 'minimal' // none (or false), errors-only, minimal, normal (or true) and verbose
}
}
export default config