-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebpack.dev.config.js
More file actions
108 lines (106 loc) · 3.28 KB
/
webpack.dev.config.js
File metadata and controls
108 lines (106 loc) · 3.28 KB
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
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const devPort = 8080;
const host = 'localhost';
module.exports = {
mode: 'development',
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader?cacheDirectory',
include: path.resolve(__dirname, 'examples'),
options: {
presets: [
['es2015', { loose: true, modules: false }],
'stage-0',
'react',
],
plugins: [
'syntax-async-functions',
'react-hot-loader/babel',
'syntax-dynamic-import',
'dynamic-import-webpack',
['import', { libraryName: 'antd', style: 'css' }],
'transform-decorators-legacy',
],
},
exclude: /node_modules/,
},
{
test: /\.(css|less)$/,
use: ['style-loader', 'css-loader?importLoaders=1', 'less-loader'],
},
{
test: /\.(ico|png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader',
options: {
name: 'fonts/[hash].[ext]',
limit: 10000,
},
},
],
},
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
test: /node_modules/,
chunks: 'initial',
name: 'vendor',
enforce: true,
},
},
},
noEmitOnErrors: true,
},
resolve: {
alias: {
'ag-grid-root': path.resolve(__dirname, '/node_modules/ag-grid'),
},
},
entry: {
bundle: [
'babel-polyfill',
`webpack-dev-server/client?http://${host}:${devPort}`,
'webpack/hot/only-dev-server',
path.resolve(__dirname, 'examples/index.js'),
],
},
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
filename: '[name].[hash:16].js',
chunkFilename: '[id].[hash:16].js',
},
devServer: {
inline: true,
port: devPort,
contentBase: path.resolve(__dirname, 'dist'),
hot: true,
publicPath: '/',
historyApiFallback: true,
host,
proxy: {
'/api': {
target: 'http://localhost',
},
'/api/ws': {
target: 'ws://localhost',
ws: true,
},
},
headers: {
'X-Frame-Options': 'sameorigin', // used iframe
},
},
plugins: [
new webpack.HotModuleReplacementPlugin(), // HMR을 사용하기 위한 플러그인
new HtmlWebpackPlugin({
filename: 'index.html',
template: `${__dirname}/examples/index.html`,
}),
],
};