-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.js
72 lines (71 loc) · 1.74 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
// local server webpack config
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const Chalk = require('chalk');
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
const port = 1997;
const host = '0.0.0.0';
module.exports = {
mode: 'development',
entry: path.resolve(__dirname, './example/index.tsx'),
output: {
path: path.join(__dirname, 'example/dist'),
filename: 'main.[hash:6].js',
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
module: {
rules: [
{
test: /\.tsx?$/,
use: ['babel-loader'],
},
{
test: /\.tsx?$/,
enforce: 'pre',
exclude: /node_modules/,
use: [
{ loader: 'tslint-loader' },
]
},
{
test: /\.s?[ac]ss$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
]
},
plugins: [
new HtmlWebpackPlugin({
hash: true,
template: path.resolve(__dirname, './example/index.html'),
}),
new ProgressBarPlugin({
complete: Chalk.blue('■'),
incomplete: Chalk.gray('□'),
format: ' :bar ' + Chalk.green.bold(':percent') + ' :msg',
clear: false
}),
new FriendlyErrorsPlugin({
compilationSuccessInfo: {
notes: [`滴滴滴: ${Chalk.green(`http://${host}:${port} 🏎`)}`],
},
onErrors: undefined
}),
new webpack.HotModuleReplacementPlugin(),
],
devtool: 'inline-source-map',
devServer: {
port,
contentBase: './dist',
historyApiFallback: true,
host,
inline: true,
hot: true,
open: true,
stats: 'errors-only',
quiet: true
},
};