-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathwebpack.dev.js
119 lines (111 loc) · 4.35 KB
/
webpack.dev.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
const webpack = require('webpack');
const path = require('path');
const chalk = require('chalk');
const autoprefixer = require('autoprefixer');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebpackMerge = require('webpack-merge');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const commonConfig = require('./webpack.common');
const entryPath = path.join(__dirname, './src');
// const outputPath = path.join(__dirname, './dist');
const customizeTheme = require('./src/theme');
const port = 8888;
const config = {
mode: 'development',
devtool: 'source-map',
entry: [
'whatwg-fetch',
require.resolve('react-dev-utils/webpackHotDevClient'),
path.join(entryPath, './index.tsx'),
],
devServer: {
contentBase: [entryPath, './node_modules', './public'],
hot: true,
historyApiFallback: true,
inline: true,
// progress: true,
host: '0.0.0.0',
port,
proxy: {
'/api':{
target: 'http://localhost:9000/'
}
}
},
module:{
rules: [
{
oneOf: [
{
test: /\.(css|less)$/,
use: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 1,
alias: { '../img': path.join(__dirname, 'public/img') }
},
},
{
loader: require.resolve('postcss-loader'),
options: {
// Necessary for external CSS imports to work
// https://github.com/facebookincubator/create-react-app/issues/2677
ident: 'postcss',
plugins: () => [
require('postcss-flexbugs-fixes'),
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
],
flexbox: 'no-2009',
}),
],
},
},
{
loader: require.resolve('less-loader'),
options: {
sourceMap: true,
javascriptEnabled: true,
modifyVars: customizeTheme
},
},
],
},
]
}
]
},
plugins: [
new ProgressBarPlugin({
format: ' start [:bar] ' + chalk.green.bold(':percent') + ' (:elapsed seconds)',
clear: false
}),
// new webpack.DefinePlugin({
// "process.env.NODE_ENV": JSON.stringify("development")
// }),
new webpack.NamedModulesPlugin(),
// only development
// Hot Module Replacement(HMR), in most cases no options are necessary.
// @see: https://webpack.js.org/plugins/hot-module-replacement-plugin/
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
template: './public/index.html',
inject: true,
}),
// Perform type checking and linting in a separate process to speed up compilation
new ForkTsCheckerWebpackPlugin({
async: false,
watch: './src',
tsconfig: './tsconfig.json',
tslint: './tslint.json',
}),
]
}
module.exports = WebpackMerge(commonConfig, config);