-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.mix.export.js
86 lines (77 loc) · 2.35 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
80
81
82
83
84
85
86
/**
* 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 Taproot
* @author Sky Shabatura <[email protected]>
* @copyright 2020 Sky Shabatura
* @link https://taproot-theme.com
* @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 = 'taproot';
// Theme root-level files to include.
let files = [
'style.css',
'changelog.md',
'functions.php',
'compat.php',
'index.php',
'license.md',
'readme.md',
'readme.txt', // Required for WordPress.org theme review.
'screenshot.png',
'screenshot.jpg',
];
// 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.
'views',
'vendor',
'tribe',
'tribe-events',
];
// 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`,
`${exportPath}/vendor/skyshab/*/gulpfile.js`,
`${exportPath}/vendor/skyshab/*/package.json`,
`${exportPath}/vendor/skyshab/*/package-lock.json`,
`${exportPath}/vendor/skyshab/*/mix-manifest.json`,
`${exportPath}/vendor/skyshab/*/.gitignore`,
`${exportPath}/vendor/skyshab/*/.babelrc`,
];
files.forEach((file) => {
rimraf.sync(file);
});
});