@storepress/create-plugin-html 0.0.6 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -6
- package/index.js +80 -11
- package/package.json +1 -1
- package/plugin-templates/.github/workflows/deploy-github-pages.yaml.mustache +1 -0
- package/plugin-templates/eslint.config.js.mustache +133 -0
- package/plugin-templates/index-module.html.mustache +30 -0
- package/plugin-templates/index.html.mustache +47 -24
- package/plugin-templates/src/interactive/index.js.mustache +22 -0
- package/plugin-templates/src/react/index.js.mustache +41 -0
- package/{block-templates → plugin-templates/src/storepress}/Plugin.js.mustache +2 -2
- package/plugin-templates/src/storepress/index.js.mustache +20 -0
- package/plugin-templates/src/storepress/script.js.mustache +9 -0
- package/{block-templates → plugin-templates/src/storepress}/style.scss.mustache +2 -2
- package/plugin-templates/tools/changelog.js.mustache +40 -41
- package/plugin-templates/tools/package.js.mustache +47 -39
- package/plugin-templates/tools/packages-install.js.mustache +0 -2
- package/plugin-templates/tools/webpack-helpers.js.mustache +10 -37
- package/plugin-templates/tools/webpack.config.externals.js.mustache +130 -0
- package/plugin-templates/webpack.config.js.mustache +94 -85
- package/block-templates/index.js.mustache +0 -20
- package/plugin-templates/.eslintrc.js.mustache +0 -196
- package/plugin-templates/global-style.css.mustache +0 -14
- package/plugin-templates/script.js.mustache +0 -8
- package/plugin-templates/style.scss.mustache +0 -10
- /package/{block-templates → plugin-templates/src/storepress}/_mixins.scss.mustache +0 -0
|
@@ -1,60 +1,59 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
"use strict";
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
-
const fs = require(
|
|
7
|
-
const { stdout } = require('process')
|
|
6
|
+
const fs = require("fs");
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
9
|
+
* WordPress dependencies
|
|
11
10
|
*/
|
|
11
|
+
const { getPackageProp, fromProjectRoot } = require("@wordpress/scripts/utils");
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
fromProjectRoot,
|
|
16
|
-
} = require('@wordpress/scripts/utils')
|
|
13
|
+
// Get Current Version.
|
|
14
|
+
const version = getPackageProp("version");
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
// Get Changelog File.
|
|
17
|
+
const changelogFile = fromProjectRoot("changelog.txt");
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
// Read and find the changelog entry for the current version.
|
|
20
|
+
const changelogContent = fs.readFileSync(changelogFile, "utf8");
|
|
21
|
+
const lines = changelogContent.split("\n");
|
|
22
|
+
const changelogEntry = [];
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
24
|
+
const commonPattern = `^(?:\\d{4}-\\d{2}-\\d{2}|\\d{2}-\\d{2}-\\d{4})\\s*-\\s*version`;
|
|
25
|
+
const currentPattern = `${commonPattern}\\s*${version}`;
|
|
26
|
+
|
|
27
|
+
const currentExp = new RegExp(currentPattern, "i");
|
|
28
|
+
|
|
29
|
+
const sectionExp = new RegExp(commonPattern, "i");
|
|
30
|
+
|
|
31
|
+
let inSection = false;
|
|
29
32
|
|
|
30
33
|
for (const line of lines) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
// Reach current section.
|
|
35
|
+
if (currentExp.test(line)) {
|
|
36
|
+
inSection = true;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// We have to stop when we get another section.
|
|
41
|
+
if (inSection) {
|
|
42
|
+
if (sectionExp.test(line)) {
|
|
43
|
+
inSection = false;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
changelogEntry.push(line);
|
|
48
|
+
}
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
if (changelogEntry.length === 0) {
|
|
44
|
-
|
|
52
|
+
changelogEntry.push(`- No changelog entry for version ${version}.\n\n`);
|
|
45
53
|
}
|
|
46
54
|
|
|
47
|
-
//
|
|
48
|
-
const finalOutput = changelogEntry.join(
|
|
49
|
-
|
|
50
|
-
// 4. Check if running in GitHub Actions environment
|
|
51
|
-
/*if (process.env.GITHUB_OUTPUT) {
|
|
52
|
-
// If yes, write to the GITHUB_OUTPUT file to set an output variable
|
|
53
|
-
// The format `key<<DELIMITER` is used for multiline strings
|
|
54
|
-
fs.appendFileSync(process.env.GITHUB_OUTPUT, `changelog_body<<EOF\n${finalOutput}\nEOF\n`)
|
|
55
|
-
} else {
|
|
56
|
-
stdout.write(`${finalOutput}\n`)
|
|
57
|
-
}*/
|
|
55
|
+
// Prepare the final output string
|
|
56
|
+
const finalOutput = changelogEntry.join("\n").trim();
|
|
58
57
|
|
|
59
|
-
stdout.write(`## What's Changed\n\n`)
|
|
60
|
-
stdout.write(`${finalOutput}\n`)
|
|
58
|
+
process.stdout.write(`## What's Changed\n\n`);
|
|
59
|
+
process.stdout.write(`${finalOutput}\n`);
|
|
@@ -3,49 +3,50 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
-
const AdmZip = require('adm-zip');
|
|
7
|
-
const { sync: glob } = require('fast-glob');
|
|
8
|
-
const { dirname } = require('path');
|
|
9
|
-
const { stdout } = require('process');
|
|
10
|
-
const fs = require('fs-extra');
|
|
6
|
+
const AdmZip = require( 'adm-zip' );
|
|
7
|
+
const { sync: glob } = require( 'fast-glob' );
|
|
8
|
+
const { dirname, join } = require( 'path' );
|
|
9
|
+
const { stdout } = require( 'process' );
|
|
10
|
+
const fs = require( 'fs-extra' );
|
|
11
|
+
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* WordPress dependencies
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
15
|
const {
|
|
16
16
|
hasPackageProp,
|
|
17
17
|
getPackageProp,
|
|
18
18
|
hasArgInCLI,
|
|
19
|
-
} = require('@wordpress/scripts/utils');
|
|
19
|
+
} = require( '@wordpress/scripts/utils' );
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
const
|
|
21
|
+
const packageName = getPackageProp( 'name' );
|
|
22
|
+
const packageVersion = getPackageProp( 'version' );
|
|
23
23
|
|
|
24
|
-
stdout.write(`Creating package for \`${
|
|
24
|
+
stdout.write( `Creating package for \`${ packageName }\` plugin... 🎁\n\n` );
|
|
25
25
|
const zip = new AdmZip();
|
|
26
|
-
const isZip = hasArgInCLI('--zip');
|
|
26
|
+
const isZip = hasArgInCLI( '--zip' );
|
|
27
27
|
|
|
28
28
|
let files = [];
|
|
29
29
|
|
|
30
|
-
if (hasPackageProp('
|
|
30
|
+
if ( hasPackageProp( 'files' ) ) {
|
|
31
31
|
stdout.write(
|
|
32
32
|
'Using the `files` field from `package.json` to detect files:\n\n'
|
|
33
33
|
);
|
|
34
34
|
|
|
35
|
-
files = glob(getPackageProp('
|
|
35
|
+
files = glob( getPackageProp( 'files' ), {
|
|
36
36
|
caseSensitiveMatch: false,
|
|
37
|
-
});
|
|
37
|
+
} );
|
|
38
38
|
} else {
|
|
39
|
-
stdout.write(
|
|
39
|
+
stdout.write(
|
|
40
|
+
'Using Plugin Handbook best practices to discover files:\n\n'
|
|
41
|
+
);
|
|
40
42
|
// See https://developer.wordpress.org/plugins/plugin-basics/best-practices/#file-organization.
|
|
41
43
|
files = glob(
|
|
42
44
|
[
|
|
43
|
-
'admin/**',
|
|
44
45
|
'build/**',
|
|
45
46
|
'includes/**',
|
|
46
47
|
'languages/**',
|
|
47
|
-
'
|
|
48
|
-
`${
|
|
48
|
+
'templates/**',
|
|
49
|
+
`${ packageName }.php`,
|
|
49
50
|
'uninstall.php',
|
|
50
51
|
'block.json',
|
|
51
52
|
'changelog.*',
|
|
@@ -58,34 +59,41 @@ if (hasPackageProp('zip')) {
|
|
|
58
59
|
);
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
if (isZip) {
|
|
62
|
+
if ( isZip ) {
|
|
62
63
|
stdout.write(
|
|
63
|
-
`Creating archive for \`${
|
|
64
|
+
`Creating archive for \`${ packageName }\` plugin... 🎁\n\n`
|
|
64
65
|
);
|
|
65
|
-
files.forEach((file) => {
|
|
66
|
-
stdout.write(` 🥳 Adding \`${file}\`.\n`);
|
|
67
|
-
const zipDirectory = dirname(file);
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
files.forEach( ( file ) => {
|
|
67
|
+
stdout.write( ` 🥳 Adding \`${ file }\`.\n` );
|
|
68
|
+
const zipDirectory = dirname( file );
|
|
69
|
+
// Prefix every entry with the slug folder
|
|
70
|
+
const targetDir =
|
|
71
|
+
zipDirectory !== '.'
|
|
72
|
+
? join( packageName, zipDirectory )
|
|
73
|
+
: packageName;
|
|
74
|
+
zip.addLocalFile( file, targetDir );
|
|
75
|
+
} );
|
|
70
76
|
|
|
71
|
-
zip.writeZip(`./${
|
|
72
|
-
stdout.write(
|
|
77
|
+
zip.writeZip( `./${ packageName }-v${ packageVersion }.zip` );
|
|
78
|
+
stdout.write(
|
|
79
|
+
`\nDone. \`${ packageName }-v${ packageVersion }.zip\` is ready! 🎉\n`
|
|
80
|
+
);
|
|
73
81
|
} else {
|
|
74
|
-
fs.remove(
|
|
75
|
-
fs.ensureDir(
|
|
82
|
+
fs.remove( packageName ).then( () => {
|
|
83
|
+
fs.ensureDir( packageName, () => {
|
|
76
84
|
stdout.write(
|
|
77
|
-
`Creating directory for \`${
|
|
85
|
+
`Creating directory for \`${ packageName }\` plugin... 🎁\n\n`
|
|
78
86
|
);
|
|
79
87
|
|
|
80
|
-
files.forEach((file) => {
|
|
81
|
-
const to = `${
|
|
82
|
-
stdout.write(` 🥳 Adding \`${file}\`.\n`);
|
|
83
|
-
fs.copy(file, to);
|
|
84
|
-
});
|
|
88
|
+
files.forEach( ( file ) => {
|
|
89
|
+
const to = `${ packageName }/${ file }`;
|
|
90
|
+
stdout.write( ` 🥳 Adding \`${ file }\`.\n` );
|
|
91
|
+
fs.copy( file, to );
|
|
92
|
+
} );
|
|
85
93
|
|
|
86
94
|
stdout.write(
|
|
87
|
-
`\n\nDone. \`${
|
|
95
|
+
`\n\nDone. \`${ packageName }\` directory is ready! 🎉\n`
|
|
88
96
|
);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
97
|
+
} );
|
|
98
|
+
} );
|
|
91
99
|
}
|
|
@@ -19,22 +19,17 @@ const scriptHandleMap = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
const externalModulesMap = {
|
|
22
|
-
// 1. static import.
|
|
23
|
-
// '@wordpress/a11y': 'import @wordpress/a11y',
|
|
24
|
-
// '@storepress/utils': 'import @storepress/utils',
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
// 'module @wordpress/a11y' → import * as X from '@wordpress/a11y'
|
|
24
|
+
// 'import @wordpress/a11y' → module.exports = import('@wordpress/a11y')
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
// '@storepress/utils': 'module @storepress/utils',
|
|
26
|
+
'@storepress/utils' : 'module @storepress/utils',
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// driver.connect();
|
|
28
|
+
// import('@storepress/utils').then(()=>{});
|
|
29
|
+
// OR
|
|
30
|
+
// const config = await fetch('../config.json').then(response => response.json());
|
|
31
|
+
// const driver = await import(`@storepress/utils`);
|
|
32
|
+
// driver.connect();
|
|
38
33
|
|
|
39
34
|
/*
|
|
40
35
|
```html
|
|
@@ -51,29 +46,7 @@ const externalModulesMap = {
|
|
|
51
46
|
<link rel="modulepreload" href="http://example.com/wp-includes/js/dist/script-modules/interactivity/index.min.js" fetchpriority="low" />
|
|
52
47
|
<link rel="modulepreload" href="./build/storepress-utils-module.js" fetchpriority="low" />
|
|
53
48
|
```*/
|
|
54
|
-
|
|
55
|
-
// in view.js
|
|
56
|
-
// ```js
|
|
57
|
-
// "import" prefix — static import (top-level, resolved at load time)
|
|
58
|
-
// import { store, getContext } from '@wordpress/a11y';
|
|
59
|
-
// ```
|
|
60
|
-
|
|
61
|
-
// dynamic import.
|
|
62
|
-
// @see: https://github.com/WordPress/gutenberg/blob/trunk/packages/block-library/src/query/view.js#L40
|
|
63
|
-
// ```js
|
|
64
|
-
// import('@wordpress/interactivity-router').then({});
|
|
65
|
-
// ```
|
|
66
|
-
// '@wordpress/interactivity-router': 'import @wordpress/interactivity-router',
|
|
67
|
-
|
|
68
|
-
// view.js
|
|
69
|
-
|
|
70
|
-
// "import" prefix — static import (top-level, resolved at load time)
|
|
71
|
-
// import { store, getContext } from '@wordpress/interactivity';
|
|
72
|
-
|
|
73
|
-
// "module" prefix — dynamic import (lazy, resolved at runtime)
|
|
74
|
-
// const loadRouter = () => import('@wordpress/interactivity-router');
|
|
75
|
-
}
|
|
76
|
-
;
|
|
49
|
+
};
|
|
77
50
|
|
|
78
51
|
/**
|
|
79
52
|
* Default request to global transformation
|
|
@@ -145,7 +118,7 @@ function getWebPackAlias() {
|
|
|
145
118
|
//'@storepress/icons': getFile('packages/icons'),
|
|
146
119
|
//'@storepress/utils': getFile('packages/utils'),
|
|
147
120
|
//'@storepress/components': getFile('packages/components'),
|
|
148
|
-
'@
|
|
121
|
+
'@storepress/html-plugin' : getFile('storepress/index.js'),
|
|
149
122
|
};
|
|
150
123
|
}
|
|
151
124
|
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
const [
|
|
2
|
+
defaultJSConfig,
|
|
3
|
+
defaultModuleConfig,
|
|
4
|
+
] = require('@wordpress/scripts/config/webpack.config');
|
|
5
|
+
const {
|
|
6
|
+
requestToExternal,
|
|
7
|
+
requestToHandle,
|
|
8
|
+
requestToExternalModule,
|
|
9
|
+
getFile,
|
|
10
|
+
getRootFile,
|
|
11
|
+
getWebPackAlias,
|
|
12
|
+
} = require('./webpack-helpers');
|
|
13
|
+
const DependencyExtractionWebpackPlugin = require('@wordpress/dependency-extraction-webpack-plugin');
|
|
14
|
+
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
|
|
15
|
+
const webpack = require('webpack');
|
|
16
|
+
|
|
17
|
+
// Helper to route files to the correct directory
|
|
18
|
+
|
|
19
|
+
const getOutputFilename = (pathData) => {
|
|
20
|
+
|
|
21
|
+
const condition = (pathData.chunk.name.startsWith('wp-') || pathData.chunk.name.startsWith('react-'))
|
|
22
|
+
|
|
23
|
+
return condition
|
|
24
|
+
? `externals/scripts/[name].js`
|
|
25
|
+
: '[name].js';
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const getOutputFilenameAsModule = (pathData) => {
|
|
29
|
+
|
|
30
|
+
const condition = (pathData.chunk.name.startsWith('wp-') || pathData.chunk.name.startsWith('react-'))
|
|
31
|
+
|
|
32
|
+
return condition
|
|
33
|
+
? `externals/modules/[name].js`
|
|
34
|
+
: '[name].js';
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const scriptConfig = {
|
|
38
|
+
...defaultJSConfig,
|
|
39
|
+
entry : {
|
|
40
|
+
'wp-element' : {
|
|
41
|
+
import : '@wordpress/element',
|
|
42
|
+
library : {
|
|
43
|
+
name : ['wp', 'element'],
|
|
44
|
+
type : 'window'
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
'react-jsx-runtime' : {
|
|
48
|
+
import : 'react/jsx-runtime',
|
|
49
|
+
library : {
|
|
50
|
+
name : ['ReactJSXRuntime'],
|
|
51
|
+
type : 'window',
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
output : {
|
|
57
|
+
...defaultJSConfig.output,
|
|
58
|
+
filename : getOutputFilename,
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
resolve : {
|
|
62
|
+
...defaultJSConfig.resolve,
|
|
63
|
+
alias : {
|
|
64
|
+
...defaultJSConfig.resolve.alias,
|
|
65
|
+
...getWebPackAlias(),
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
plugins : [
|
|
70
|
+
...defaultJSConfig.plugins,
|
|
71
|
+
...defaultJSConfig.plugins.filter(
|
|
72
|
+
(plugin) =>
|
|
73
|
+
plugin.constructor.name !== 'DependencyExtractionWebpackPlugin'
|
|
74
|
+
),
|
|
75
|
+
new webpack.optimize.LimitChunkCountPlugin({maxChunks : 1}),
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const moduleConfig = {
|
|
80
|
+
...defaultModuleConfig,
|
|
81
|
+
entry : {
|
|
82
|
+
// ...defaultModuleConfig.entry(),
|
|
83
|
+
// 'custom-module': getFile( 'custom-module.js' ),
|
|
84
|
+
/*'storepress-utils-module': {
|
|
85
|
+
import: '@storepress/utils/build-module/index.js',
|
|
86
|
+
library: {
|
|
87
|
+
type: 'module',
|
|
88
|
+
},
|
|
89
|
+
}*/
|
|
90
|
+
|
|
91
|
+
'wp-interactivity' : {
|
|
92
|
+
import : '@wordpress/interactivity',
|
|
93
|
+
library : {
|
|
94
|
+
type : 'module'
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
output : {
|
|
100
|
+
...defaultModuleConfig.output,
|
|
101
|
+
filename : getOutputFilenameAsModule,
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
resolve : {
|
|
105
|
+
...defaultModuleConfig.resolve,
|
|
106
|
+
alias : {
|
|
107
|
+
...defaultModuleConfig.resolve.alias,
|
|
108
|
+
...getWebPackAlias(),
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
plugins : [
|
|
113
|
+
...defaultModuleConfig.plugins,
|
|
114
|
+
|
|
115
|
+
...defaultModuleConfig.plugins.filter(
|
|
116
|
+
(plugin) =>
|
|
117
|
+
plugin.constructor.name !== 'DependencyExtractionWebpackPlugin'
|
|
118
|
+
),
|
|
119
|
+
|
|
120
|
+
new webpack.optimize.LimitChunkCountPlugin({maxChunks : 1}),
|
|
121
|
+
|
|
122
|
+
// Removes the empty `.js` files generated by webpack but
|
|
123
|
+
// sets it after WP has generated its `*.asset.php` file.
|
|
124
|
+
new RemoveEmptyScriptsPlugin({
|
|
125
|
+
stage : RemoveEmptyScriptsPlugin.STAGE_AFTER_PROCESS_PLUGINS,
|
|
126
|
+
}),
|
|
127
|
+
],
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
module.exports = [scriptConfig, moduleConfig];
|
|
@@ -1,104 +1,113 @@
|
|
|
1
1
|
const [
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
]
|
|
2
|
+
defaultJSConfig,
|
|
3
|
+
defaultModuleConfig,
|
|
4
|
+
] = require('@wordpress/scripts/config/webpack.config');
|
|
5
5
|
const {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' );
|
|
6
|
+
requestToExternal,
|
|
7
|
+
requestToHandle,
|
|
8
|
+
requestToExternalModule,
|
|
9
|
+
getFile,
|
|
10
|
+
getRootFile,
|
|
11
|
+
getWebPackAlias,
|
|
12
|
+
} = require('./tools/webpack-helpers');
|
|
13
|
+
const DependencyExtractionWebpackPlugin = require('@wordpress/dependency-extraction-webpack-plugin');
|
|
14
|
+
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
|
|
16
15
|
|
|
17
16
|
const scriptConfig = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
getRootFile('script.js'),
|
|
17
|
+
...defaultJSConfig,
|
|
18
|
+
entry : {
|
|
19
|
+
[`react-example`] : [
|
|
20
|
+
getFile('react/index.js'),
|
|
23
21
|
],
|
|
24
|
-
'storepress-utils': {
|
|
25
|
-
import: '@storepress/utils/build-module/index.js',
|
|
26
|
-
library: {
|
|
27
|
-
name: ['StorePress','Utils'],
|
|
28
|
-
type: 'window'
|
|
29
|
-
},
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
22
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
'storepress-utils' : {
|
|
24
|
+
import : '@storepress/utils/build-module/index.js',
|
|
25
|
+
library : {
|
|
26
|
+
name : ['StorePress', 'Utils'],
|
|
27
|
+
type : 'window',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
40
30
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
),
|
|
47
|
-
new WoocommerceDependencyExtractionWebpackPlugin( {
|
|
48
|
-
requestToExternal,
|
|
49
|
-
requestToHandle,
|
|
50
|
-
requestToExternalModule,
|
|
51
|
-
} ),
|
|
31
|
+
[`script-example`] : [
|
|
32
|
+
getFile('storepress/style.scss'),
|
|
33
|
+
getFile('storepress/script.js'),
|
|
34
|
+
],
|
|
35
|
+
},
|
|
52
36
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
37
|
+
resolve : {
|
|
38
|
+
...defaultJSConfig.resolve,
|
|
39
|
+
alias : {
|
|
40
|
+
...defaultJSConfig.resolve.alias,
|
|
41
|
+
...getWebPackAlias(),
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
plugins : [
|
|
46
|
+
...defaultJSConfig.plugins,
|
|
47
|
+
...defaultJSConfig.plugins.filter(
|
|
48
|
+
(plugin) =>
|
|
49
|
+
plugin.constructor.name !== 'DependencyExtractionWebpackPlugin'
|
|
50
|
+
),
|
|
51
|
+
|
|
52
|
+
new DependencyExtractionWebpackPlugin({
|
|
53
|
+
requestToExternal,
|
|
54
|
+
requestToHandle,
|
|
55
|
+
requestToExternalModule,
|
|
56
|
+
}),
|
|
57
|
+
|
|
58
|
+
// Removes the empty `.js` files generated by webpack but
|
|
59
|
+
// sets it after WP has generated its `*.asset.php` file.
|
|
60
|
+
new RemoveEmptyScriptsPlugin({
|
|
61
|
+
stage : RemoveEmptyScriptsPlugin.STAGE_AFTER_PROCESS_PLUGINS,
|
|
62
|
+
}),
|
|
63
|
+
],
|
|
64
|
+
}
|
|
60
65
|
|
|
61
66
|
const moduleConfig = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// ...defaultModuleConfig.entry(),
|
|
67
|
-
// 'custom-module': getFile( 'custom-module.js' ),
|
|
68
|
-
/*'storepress-utils-module': {
|
|
67
|
+
...defaultModuleConfig,
|
|
68
|
+
entry : {
|
|
69
|
+
'interactive-example' : getFile('interactive/index.js'),
|
|
70
|
+
'storepress-utils-module': {
|
|
69
71
|
import: '@storepress/utils/build-module/index.js',
|
|
70
72
|
library: {
|
|
71
73
|
type: 'module',
|
|
72
74
|
},
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
[`module-example`] : [
|
|
78
|
+
getFile('storepress/style.scss'),
|
|
79
|
+
getFile('storepress/script.js'),
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
resolve : {
|
|
84
|
+
...defaultModuleConfig.resolve,
|
|
85
|
+
alias : {
|
|
86
|
+
...defaultModuleConfig.resolve.alias,
|
|
87
|
+
...getWebPackAlias(),
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
plugins : [
|
|
92
|
+
...defaultModuleConfig.plugins,
|
|
75
93
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
...getWebPackAlias(),
|
|
81
|
-
},
|
|
82
|
-
},
|
|
94
|
+
...defaultModuleConfig.plugins.filter(
|
|
95
|
+
(plugin) =>
|
|
96
|
+
plugin.constructor.name !== 'DependencyExtractionWebpackPlugin'
|
|
97
|
+
),
|
|
83
98
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
),
|
|
90
|
-
new DependencyExtractionWebpackPlugin( {
|
|
91
|
-
requestToExternal,
|
|
92
|
-
requestToHandle,
|
|
93
|
-
requestToExternalModule,
|
|
94
|
-
} ),
|
|
99
|
+
new DependencyExtractionWebpackPlugin({
|
|
100
|
+
requestToExternal,
|
|
101
|
+
requestToHandle,
|
|
102
|
+
requestToExternalModule,
|
|
103
|
+
}),
|
|
95
104
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
// Removes the empty `.js` files generated by webpack but
|
|
106
|
+
// sets it after WP has generated its `*.asset.php` file.
|
|
107
|
+
new RemoveEmptyScriptsPlugin({
|
|
108
|
+
stage : RemoveEmptyScriptsPlugin.STAGE_AFTER_PROCESS_PLUGINS,
|
|
109
|
+
}),
|
|
110
|
+
],
|
|
102
111
|
};
|
|
103
112
|
|
|
104
|
-
module.exports = [
|
|
113
|
+
module.exports = [scriptConfig, moduleConfig];
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { createStorePressPlugin } from '@storepress/utils';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { Plugin } from './Plugin';
|
|
10
|
-
|
|
11
|
-
const {{pascaleSlug}} = createStorePressPlugin( {
|
|
12
|
-
selector: '[data-{{kebabSlug}}]',
|
|
13
|
-
options: {},
|
|
14
|
-
plugin: Plugin,
|
|
15
|
-
namespace: '{{pascaleSlug}}',
|
|
16
|
-
} );
|
|
17
|
-
|
|
18
|
-
{{pascaleSlug}}.setup();
|
|
19
|
-
|
|
20
|
-
export default {{pascaleSlug}};
|