-
Notifications
You must be signed in to change notification settings - Fork 27
/
webpack.prod.js
98 lines (89 loc) · 2.94 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
const common = require("./webpack.common");
const { merge } = require('webpack-merge');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const WebpackRTLPlugin = require("webpack-rtl-plugin");
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const FileManagerPlugin = require('filemanager-webpack-plugin');
const { vueEntries } = require('./webpack-entry-list.js');
const prodConfig = {
mode: "production", // production | development
watch: false,
entry: {
['admin-multi-directory-builder']: "./assets/src/js/admin/multi-directory-builder.js",
['admin-settings-manager']: "./assets/src/js/admin/settings-manager.js",
},
plugins: [
new MiniCssExtractPlugin({
filename: "../css/[name].min.css",
minify: true,
}),
new WebpackRTLPlugin({
minify: true,
filename: "../css/[name].rtl.min.css",
}),
new CleanWebpackPlugin({
dry: false,
cleanOnceBeforeBuildPatterns: [ '../css/*.map', '../js/*.map' ],
dangerouslyAllowCleanPatternsOutsideProject: true,
}),
new FileManagerPlugin({
events: {
onEnd: [
{
copy: [
{ source: './assets', destination: './__build/directorist/directorist/assets' },
{ source: './blocks', destination: './__build/directorist/directorist/blocks' },
{ source: './languages', destination: './__build/directorist/directorist/languages' },
{ source: './includes', destination: './__build/directorist/directorist/includes' },
{ source: './templates', destination: './__build/directorist/directorist/templates' },
{ source: './views', destination: './__build/directorist/directorist/views' },
{ source: './*.php', destination: './__build/directorist/directorist' },
{ source: './*.txt', destination: './__build/directorist/directorist' },
],
},
{
delete: ['./__build/directorist/directorist/assets/src'],
},
{
archive: [
{ source: './__build/directorist', destination: './__build/directorist.zip' },
],
},
{
delete: ['./__build/directorist'],
},
],
},
}),
],
output: {
filename: "../js/[name].min.js",
},
};
const devConfig = {
mode: "development", // production | development
watch: true,
entry: vueEntries,
plugins: [
new MiniCssExtractPlugin({
filename: "../css/[name].css",
minify: false,
}),
new WebpackRTLPlugin({
minify: false,
}),
],
output: {
filename: "../js/[name].js",
},
devtool: 'source-map'
};
let configs = [];
common.forEach(element => {
const _devConfig = merge( element, devConfig );
_devConfig.watch = false;
configs.push( _devConfig );
const _prodConfig = merge( element, prodConfig );
configs.push( _prodConfig );
});
module.exports = configs;