-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.mix.export.js
95 lines (83 loc) · 2.54 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
87
88
89
90
91
92
93
94
95
/**
* Plugin Export Script
*
* Exports the production-ready plugin 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.
*
* This configuration is a copy of the configuration from https://github.com/justintadlock/mythic/
* modified to fit Pressmodo's plugins purposes.
*/
// 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 = 'wp-simple-menu-icons';
// Plugin root-level files to include.
let files = [
'wp-simple-menu-icons.php',
'uninstall.php',
'readme.txt',
];
// Folders to include.
let folders = [
'includes',
'languages',
'dist',
'templates',
'src',
'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`,
`${exportPath}/vendor/composer/installers`,
`${exportPath}/dist/mix-manifest.json`,
`${exportPath}/dist/mix-js.map`,
`${exportPath}/dist/svg`,
`${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}/dist/**/*.map`,
`${exportPath}/vendor/**/*.md`,
`${exportPath}/vendor/**/*.yml`,
`${exportPath}/vendor/**/*.yaml`,
`${exportPath}/vendor/**/*.dist`,
`${exportPath}/vendor/**/tests`,
`${exportPath}/vendor/**/.github`,
];
files.forEach( file => {
rimraf.sync( file );
} );
} );