-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
97 lines (83 loc) · 2.55 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
const webpack = require('webpack');
const path = require('path');
const Dotenv = require('dotenv-webpack');
const history = require('connect-history-api-fallback');
const convert = require('koa-connect');
const sourcePath = path.join(__dirname, 'src');
const outPath = path.join(__dirname, './build');
// plugins
const WebpackNotifierPlugin = require('webpack-notifier');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const createStyledComponentsTransformer = require('typescript-plugin-styled-components').default;
const styledComponentsTransformer = createStyledComponentsTransformer();
module.exports = {
mode: 'development',
context: sourcePath,
entry: './main.tsx',
output: {
filename: '[name].[hash].js',
chunkFilename: '[name].[hash].chunk.js',
path: outPath,
devtoolModuleFilenameTemplate: '[absolute-resource-path]',
publicPath: '/'
},
target: 'web',
resolve: {
extensions: ['.ts', '.tsx', '.js'],
alias: {
src: path.resolve(__dirname, 'src')
}
},
devtool: 'source-map',
module: {
// noParse: /(mapbox-gl)\.js$/,
rules: [
{
test: /\.(ts|tsx)$/,
use: [
/*
{
loader: 'babel-loader'
},
*/
{
loader: 'ts-loader',
options: {
getCustomTransformers: () => ({before: [styledComponentsTransformer]})
}
}
]
},
{test: /\.html$/, use: 'html-loader'}
]
},
plugins: [
/*
new BundleAnalyzerPlugin({
analyzerMode: 'static'
}),
*/
new WebpackNotifierPlugin({alwaysNotify: true}),
new webpack.optimize.AggressiveMergingPlugin(),
new HtmlWebpackPlugin({
template: 'index.html'
}),
new Dotenv({
path: '.env',
safe: false
}),
],
node: {
// workaround for webpack-dev-server issue
// https://github.com/webpack/webpack-dev-server/issues/60#issuecomment-103411179
fs: 'empty',
net: 'empty',
child_process: 'empty'
}
};
module.exports.serve = {
content: [__dirname],
add: (app, middleware, options) => {
app.use(convert(history({})));
},
};