forked from fossabot/MiniValine
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathwebpack.config.js
More file actions
100 lines (99 loc) · 2.3 KB
/
Copy pathwebpack.config.js
File metadata and controls
100 lines (99 loc) · 2.3 KB
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
var path = require('path')
var libraryName = 'MiniValine'
var ROOT_PATH = path.resolve(__dirname)
var BUILD_PATH = path.resolve(ROOT_PATH, 'dist')
const version = require('./package.json').version
var CDN_PATH = 'https://cdn.jsdelivr.net/gh/amehime/MiniValine@v' + version + '/dist/'
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const webpack = require('webpack')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
var plugins = [
new webpack.optimize.ModuleConcatenationPlugin()
]
var WEBPACK_CONFIG = {
mode: 'production',
performance: { hints: false },
entry: {
MiniValine: './src/index.js'
},
optimization: {
minimize: false
},
output: {
path: BUILD_PATH,
publicPath: 'http://localhost:8088/dist/',
filename: '[name].min.js',
chunkFilename: libraryName + '.[name].min.js',
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true
},
devtool: 'cheap-module-source-map',
devServer: {
publicPath: '/dist/',
inline: true,
port: 8088
},
module: {
rules: [{
test: /\.js$/,
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
},
{
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
'postcss-loader',
'sass-loader'
]
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
'postcss-loader'
]
},
{
test: /\.(png|jpg)$/,
use: ['url-loader?limit=1024*10']
}
]
},
plugins: plugins
}
if (process.env.env_config == 'build') {
plugins.push(new CleanWebpackPlugin())
plugins.push(new UglifyJsPlugin({
parallel: 4,
sourceMap: false,
parallel: true,
uglifyOptions: {
warnings: false,
ie8: true,
safari10: true,
output: {
comments: false,
beautify: false,
ascii_only: true
},
compress: {
collapse_vars: true,
reduce_vars: true
}
}
}))
WEBPACK_CONFIG.devtool = false
WEBPACK_CONFIG.optimization.minimize = true
WEBPACK_CONFIG.output.publicPath = CDN_PATH
} else {
plugins.push(new webpack.LoaderOptionsPlugin())
plugins.push(new webpack.NamedModulesPlugin())
plugins.push(new webpack.HotModuleReplacementPlugin())
}
module.exports = WEBPACK_CONFIG