-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.prod.babel.js
105 lines (99 loc) · 2.46 KB
/
webpack.config.prod.babel.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
"use strict"
import CopyWebpackPlugin from "copy-webpack-plugin"
import ExtractTextPlugin from "extract-text-webpack-plugin"
import HtmlWebpackPlugin from "html-webpack-plugin"
import UglifyJsPlugin from "uglifyjs-webpack-plugin"
import autoprefixer from "autoprefixer"
import path from "path"
import webpack from "webpack"
let INPUT = `/src/`
let OUTPUT = `/prod/`
let plugins = [
new HtmlWebpackPlugin({
filename: __dirname + `${OUTPUT}index.html`,
template: __dirname + `/${INPUT}html/index.ejs`,
cache: true,
hash: true,
inject: 'body',
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: false,
minifyCSS: false,
minifyURLs: false,
removeScriptTypeAttributes: true
}
}),
new CopyWebpackPlugin([{
from: __dirname + `/${INPUT}img/`,
to: __dirname + `/${OUTPUT}assets/img/`
}]),
new CopyWebpackPlugin([{
from: __dirname + `/${INPUT}model/`,
to: __dirname + `/${OUTPUT}assets/model/`
}]),
new ExtractTextPlugin({
filename: 'css/bundle.css',
disable: false,
allChunks: true
}),
new webpack.optimize.UglifyJsPlugin({
include: /\.min\.js$/,
minimize: true
})
]
const config = {
entry: [
path.resolve(__dirname, `./${INPUT}js/app.js`),
path.resolve(__dirname, `./${INPUT}scss/app.scss`),
],
output: {
path: path.resolve(__dirname, `./${OUTPUT}assets/`),
filename: 'js/bundle.js'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
comments: false,
compact: true
}
},
{
test: /\.(scss|css)$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [{
loader: 'css-loader',
options: {
url: false,
modules: true,
sourceMap: false,
minimize: true,
camelCase: true,
importLoaders: 1,
localIdentName: '[local]'
}
}, {
loader: 'postcss-loader'
},{
loader: 'sass-loader',
options: {
sourceMap: false
}
}]
})
},
]
},
plugins: plugins
};
module.exports = config