-
Notifications
You must be signed in to change notification settings - Fork 43
/
webpack.mix.export.js
79 lines (67 loc) · 1.93 KB
/
webpack.mix.export.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
/**
* Theme Export Script
*
* Exports the production-ready theme with only the files and folders needed for
* uploading to a site or zipping. Edit the `files` or `folders` variables if
* you need to change something.
*
* @package Mythic
* @author Justin Tadlock <[email protected]>
* @copyright 2018 Justin Tadlock
* @link https://themehybrid.com/themes/mythic
* @license https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0-or-later
*/
// Import required packages.
const mix = require( 'laravel-mix' );
const rimraf = require( 'rimraf' );
const fs = require( 'fs' );
// Folder name to export the files to.
let exportPath = 'mythic';
// Theme root-level files to include.
let files = [
'style.css',
'changelog.md',
'functions.php',
'index.php',
'license.md',
'readme.md',
// 'readme.txt', // Required for WordPress.org theme review.
'screenshot.png'
];
// Folders to include.
let folders = [
'app',
'dist',
'resources/lang',
// 'resources/js', // Required for WordPress.org theme review.
// 'resources/scss', // Required for WordPress.org theme review.
'resources/views',
'vendor'
];
// Delete the previous export to start clean.
rimraf.sync( exportPath );
// Loop through the root files and copy them over.
files.forEach( file => {
if ( fs.existsSync( file ) ) {
mix.copy( file, `${exportPath}/${file}` );
}
} );
// Loop through the folders and copy them over.
folders.forEach( folder => {
if ( fs.existsSync( folder ) ) {
mix.copyDirectory( folder, `${exportPath}/${folder}` );
}
} );
// Delete the `vendor/bin` and `vendor/composer/installers` folder, which can
// get left over, even in production. Mix will also create an additional
// `mix-manifest.json` file in the root, which we don't need.
mix.then( () => {
let files = [
'mix-manifest.json',
`${exportPath}/vendor/bin`,
`${exportPath}/vendor/composer/installers`
];
files.forEach( file => {
rimraf.sync( file );
} );
} );