This repository was archived by the owner on Sep 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathwebpack.dev.babel.js
73 lines (62 loc) · 2.01 KB
/
webpack.dev.babel.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
/**
* DEVELOPMENT WEBPACK CONFIGURATION
*/
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const createStyledComponentsTransformer = require('typescript-plugin-styled-components')
.default;
const styledComponentsTransformer = createStyledComponentsTransformer();
const ErrorOverlayPlugin = require('error-overlay-webpack-plugin');
module.exports = require('./webpack.base.babel')({
mode: 'development',
// Add hot reloading in development
entry: [
'react-hot-loader/patch',
'webpack-hot-middleware/client?reload=true',
path.join(process.cwd(), 'app/app.tsx'), // Start with js/app.js
],
// Don't use hashes in dev mode for better performance
output: {
filename: '[name].js',
chunkFilename: '[name].chunk.js',
},
optimization: {
splitChunks: {
chunks: 'all',
},
},
// Add development plugins
plugins: [
new ErrorOverlayPlugin(),
new webpack.HotModuleReplacementPlugin(), // Tell webpack we want hot reloading
new HtmlWebpackPlugin({
inject: true, // Inject all files that are generated by webpack, e.g. bundle.js
template: 'app/index.html',
}),
new CircularDependencyPlugin({
exclude: /a\.js|node_modules/, // exclude node_modules
failOnError: false, // show a warning when there is a circular dependency
}),
],
tsLoaders: [
{ loader: 'babel-loader' }, // using babel after typescript transpiles to target es6
{
loader: 'ts-loader',
options: {
transpileOnly: true, // fork-ts-checker-webpack-plugin is used for type checking
logLevel: 'info',
getCustomTransformers: () => ({
before: [styledComponentsTransformer],
}),
},
},
],
// Emit a source map for easier debugging
// See https://webpack.js.org/configuration/devtool/#devtool
devtool: 'cheap-module-source-map',
performance: {
hints: false,
},
});