-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ts
91 lines (81 loc) · 2.21 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
import webpack from 'webpack'
import path from 'path'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
const isProd = process.env.NODE_ENV === 'production'
const config: webpack.Configuration = {
entry: {
app: ['./client/app/app.tsx', 'webpack-hot-middleware/client?reload=true']
// 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?$/,
use: [
{
loader: 'babel-loader',
options: {
babelrc: false,
plugins: ['react-hot-loader/babel']
}
},
'awesome-typescript-loader'
]
},
{
test: /\.sass$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
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: [
// webpack, not react hmr
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
new HtmlWebpackPlugin({
template: './client/public/index.html',
inject: 'body'
}),
new ExtractTextPlugin({
filename: 'css/style.css'
})
],
devServer: {
contentBase: './client/public',
historyApiFallback: true,
stats: 'minimal' // none (or false), errors-only, minimal, normal (or true) and verbose
}
}
export default config