-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.config.js
56 lines (49 loc) · 1.35 KB
/
webpack.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
var webpack = require("webpack"),
ExtractTextPlugin = require("extract-text-webpack-plugin"),
HtmlPlugin = require("./plugins/html-plugin"),
path = require("path");
var cssExtractTextPlugin = new ExtractTextPlugin("[name].css");
module.exports = {
devServer: {
port: 9000,
historyApiFallback: true,
},
entry: {
"script": "./scripts/index.js",
"style": "./styles/index.less",
},
module: {
rules: [
{ test: /\.txt$/, loader: "text-loader" },
{ test: /\.json$/, loader: "json-loader"},
{ test: /\.js$/, exclude: /(node_modules|bower_components)\//, loader: "babel-loader"},
{ test: /\.(ttf.*|eot.*|woff.*|ogg|mp3)$/, loader: "file-loader"},
{ test: /.(png|jpe?g|gif|svg.*)$/, loader: "file-loader"},
{
test: /\.css$/,
loader: cssExtractTextPlugin.extract("css-loader"),
},
{
test: /\.less$/,
loader: cssExtractTextPlugin.extract("css-loader!less-loader"),
},
],
},
plugins: [
cssExtractTextPlugin,
new HtmlPlugin("index.html"),
new webpack.DefinePlugin({
CONFIG: JSON.stringify(require("config")),
}),
],
resolve: {
modules: [
path.resolve(__dirname, "src"),
path.resolve(__dirname, "node_modules"),
],
},
output: {
path: path.join(__dirname, "dist"),
filename: "[name].js",
},
};