This repository has been archived by the owner on Jun 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.prod.js
113 lines (105 loc) · 2.89 KB
/
webpack.prod.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
const fs = require('fs');
const path = require('path');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const webpack = require('webpack');
const yaml = require('js-yaml');
const bc = yaml.safeLoad(fs.readFileSync(path.join('_config.yml'), 'utf8'));
const THEME_DIR = path.join(__dirname,'themes',bc.meta.blog_theme)
// plugin inits
const extractCss = new ExtractTextPlugin({
filename: "[name].css"
});
// to ignore the unicode table(2mb) for unicode slug
const ignorePlugin = new webpack.IgnorePlugin(/unicode\/category\/So/);
const uglify = new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
drop_console: false,
}
});
// end plugin inits
module.exports = {
entry: {
vendors: [path.join(THEME_DIR,'static','js','prism.js')],
main: path.join(THEME_DIR,'static','js','main.js')
},
output: {
path: path.join(__dirname, 'dist','assets'),
filename: '[name].js'
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
use: [
{loader:'babel-loader'}
],
exclude: /node_modules/
},
{
test: /\.(sass|scss)$/,
use: extractCss.extract({
use: [{
loader: "css-loader",
options: { minimize: true }
},
{
loader: "postcss-loader"
},
{
loader: "sass-loader",
options: { minimize: true }
}],
// use style-loader in development
fallback: "style-loader"
})
},
{
test: /\.css$/,
use: extractCss.extract({
use:
[
{
loader:'css-loader',
options: { minimize: true }
}
],
fallback: "style-loader"
})
},
{
test: /\.(png|jpg|gif|svg)$/,
use: [
{
loader:'file-loader',
query: {
name: "[name].[ext]",
useRelativePath: false,
publicPath: '',
outputPath: 'img/'
}
}
]
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: [
{
loader:'file-loader',
query: {
name: "[name].[ext]",
useRelativePath: false,
publicPath: '',
outputPath: 'fonts/'
}
}
]
}
]
},
plugins: [
ignorePlugin,
extractCss,
uglify
]
}