-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.production.config.js
80 lines (76 loc) · 2.22 KB
/
webpack.production.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
75
76
77
78
79
80
'use strict';
var webpack = require('webpack');
var path = require('path');
var WebpackShellPlugin = require('webpack-shell-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var StringReplacerPlugin = require('webpack-string-replacer-plugin');
var ZipPlugin = require('zip-webpack-plugin');
module.exports = {
entry: {
prod: './src/prod.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'assets/[name].js',
},
module: {
rules: []
},
plugins: [
new StringReplacerPlugin({
assets: ['./dist/assets/*.css.twig'],
replaceValue: '"{{',
newValue: '{{'
}),
new StringReplacerPlugin({
assets: ['./dist/assets/*.css.twig'],
replaceValue: '}}"',
newValue: '}}'
}),
new WebpackShellPlugin({
onBuildEnd: ['node removefiles.js']
}),
new CopyWebpackPlugin([
{ from: './dist/assets/styles.css.twig', to: 'assets/styles.css.twig' },
{ from: './src/settings.json', to: 'settings.json' },
{ from: './src/assets', to: 'assets' },
{ from: './src/config', to: 'config' },
{ from: './src/layouts', to: 'layouts' },
{ from: './src/pages', to: 'pages' },
{ from: './src/partials', to: 'partials' },
{ from: './src/screenshots', to: 'screenshots' },
{ from: './src/assets/app.js', to: 'assets/app.js.twig' },
{ from: 'screenshot.png', to: 'screenshot.png' },
{ from: 'README.md', to: 'README.md' },
{
from: {
glob: '.editorconfig',
dot: true
},
to: '.editorconfig',
toType: 'file'
},
{
from: {
glob: '.gitignore',
dot: true
},
to: '.gitignore',
toType: 'file'
}
], { copyUnmodified: true }),
new ZipPlugin({
filename: 'theme.zip',
pathPrefix: 'theme/1.0.0',
include: [/\.twig$/, /\.md$/, /\.jpg$/, /\.jpge$/, /\.png$/, /\.ico$/, /\.json$/, '.gitignore', '.editorconfig'],
exclude: [/\.html$/, /\.css$/, /\.js$/, /\.php$/],
fileOptions: {
mtime: new Date(),
mode: 0o100664,
compress: true,
forceZip64Format: false,
}
})
]
}