/
webpack.config.js
74 lines (72 loc) · 2.03 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const ExtractTextWebpackPlugin = require("extract-text-webpack-plugin");
const IgnoreAssetsWebpackPlugin = require("ignore-assets-webpack-plugin");
const StyleExtHTMLWebpackPlugin = require("style-ext-html-webpack-plugin");
const HTMLWebpackPlugin = require("html-webpack-plugin");
const nib = require("nib");
const path = require("path");
const webpack = require("webpack");
const INDEX_PATH = path.resolve(__dirname, "index.html");
const STYLES_PATH = path.resolve(__dirname, "index.styl");
const FAVICON_PATH = path.resolve(__dirname, "favicon.png");
module.exports = {
target: "web",
entry: [INDEX_PATH, STYLES_PATH],
output: {
filename: "bundle.js",
publicPath: "/"
},
module: {
rules: [
{
test: /\.(html)$/,
loader: "html-loader",
options: {
minimize: true
}
},
{
test: /\.(css|styl)$/,
loader: ExtractTextWebpackPlugin.extract({
fallback: { loader: "style-loader" },
use: [
"css-loader",
{
loader: "stylus-loader",
options: {
use: [nib()]
}
}
]
})
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: "file-loader?name=fonts/[hash].[ext]"
},
{
test: /\.(png)$/,
loader: "url-loader?limit=100000"
}
]
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new HTMLWebpackPlugin({
filename: "index.html",
template: INDEX_PATH,
chunks: ["index.css"]
}),
new ExtractTextWebpackPlugin("index.css"),
new StyleExtHTMLWebpackPlugin({ minify: true }),
new CopyWebpackPlugin([
{ from: "files", to: "files" },
{ from: "images", to: "images" }
]),
new FaviconsWebpackPlugin({ logo: FAVICON_PATH, prefix: "icons/[hash]/" }),
new IgnoreAssetsWebpackPlugin({
ignore: "bundle.js"
})
]
};