-
Notifications
You must be signed in to change notification settings - Fork 18
/
webpack.dev.config.js
94 lines (91 loc) · 2.93 KB
/
webpack.dev.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
var path = require("path");
var packageJson = require(path.join(__dirname, "package.json"));
var webpack = require("webpack");
var appDir = path.resolve(__dirname, "src");
var testDir = path.resolve(__dirname, "test");
let createConfig = infoJson => ({
entry: {
vendors: [
"react-hot-loader",
// For react hot loader
"react-hot-loader/patch",
].concat(Object.keys(packageJson.dependencies)),
app: [
"react-hot-loader",
// For react hot loader
"react-hot-loader/patch",
// For module replacement
"webpack-dev-server/client?http://localhost:6002",
"webpack/hot/only-dev-server",
path.join(__dirname, "src", "Index.hmr.tsx"),
],
},
resolve: {
extensions: [".tsx", ".ts", ".js", ".less", ".css", ".scss"],
},
output: {
filename: "[name].js",
publicPath: "http://localhost:6002/assets/",
},
watch: true,
module: {
loaders: [
{
test: /\.csv$/,
loader: "csv-loader",
options: {
dynamicTyping: false,
header: true,
skipEmptyLines: true,
},
},
{ test: /\.tsx?$/, loaders: ["ts-loader"], include: [appDir, testDir] },
{
test: /\.css$/,
exclude: /\.import\.css$/,
loader: "style-loader!css",
include: appDir,
},
{
test: /\.scss$/,
exclude: /\.module\.scss$/,
loader: "style-loader!css-loader!postcss-loader!sass-loader",
include: appDir,
},
{
test: /\.module\.scss$/,
loader:
"style-loader!css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss-loader!sass-loader",
include: appDir,
},
{ test: /\.svg$/, loader: "svg-inline-loader" },
{
test: /\.(woff|woff2)$/,
loader: "url-loader",
options: {
name: "fonts/[hash].[ext]",
limit: 5000,
mimetype: "application/font-woff",
},
},
{
test: /\.(ttf|eot)$/,
loader: "file-loader",
options: {
name: "fonts/[hash].[ext]",
},
},
{ test: /\.(jpg|png|gif)$/, loader: "file-loader?name=[name].[ext]", include: appDir },
],
},
devtool: "inline-source-map",
plugins: [
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: '"development"',
},
}),
new webpack.HotModuleReplacementPlugin(),
],
});
module.exports = createConfig;