-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.mix.export.js
86 lines (74 loc) · 2.21 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
/**
* Plugin export script..
*
* Exports the production-ready plugin with only the files and folders needed for
* uploading to a site or zipping.
*/
// 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 = 'pressmodo-onboarding';
// Plugin root-level files to include.
let files = [
'pressmodo-onboarding.php',
'readme.txt',
'uninstall.php',
];
// Folders to include.
let folders = [
'dist',
'includes',
'languages',
'src',
'resources/images',
'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`,
`${exportPath}/vendor/composer/installers`,
`${exportPath}/dist/mix-manifest.json`,
`${exportPath}/dist/mix-js.map`,
`${exportPath}/vendor/dealerdirect`,
`${exportPath}/vendor/phpcompatibility`,
`${exportPath}/vendor/squizlabs`,
`${exportPath}/vendor/wp-coding-standards`,
`${exportPath}/vendor/**/.git`,
`${exportPath}/vendor/**/.editorconfig`,
`${exportPath}/vendor/**/.gitignore`,
`${exportPath}/vendor/**/composer.json`,
`${exportPath}/vendor/**/composer.lock`,
`${exportPath}/vendor/**/LICENSE`,
`${exportPath}/vendor/**/phpcs.xml`,
`${exportPath}/vendor/**/readme.md`,
`${exportPath}/vendor/**/.gitattributes`,
`${exportPath}/vendor/tgmpa/tgm-plugin-activation/plugins`,
`${exportPath}//vendor/nikic/fast-route/test`,
`${exportPath}/dist/**/*.map`,
`${exportPath}/dist/*.js`,
];
files.forEach( file => {
rimraf.sync( file );
} );
} );