@eightshift/frontend-libs-tailwind 3.5.0 → 4.0.0-beta.2
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/CHANGELOG.md +19 -0
- package/README.md +231 -0
- package/bun/build.mjs +357 -0
- package/bun/cli.mjs +77 -0
- package/bun/css.mjs +145 -0
- package/bun/discovery.mjs +121 -0
- package/bun/editor-native.mjs +191 -0
- package/bun/editor-pure-jsx.mjs +381 -0
- package/bun/editor.mjs +215 -0
- package/bun/eightshift-css.mjs +66 -0
- package/bun/eightshift-discovery.mjs +140 -0
- package/bun/flat-publication.mjs +411 -0
- package/bun/index.mjs +118 -0
- package/bun/media.mjs +50 -0
- package/bun/plugin-capabilities.mjs +11 -0
- package/bun/preset.mjs +120 -0
- package/bun/publish.mjs +236 -0
- package/bun/release.mjs +207 -0
- package/{webpack/responsive-compiler.mjs → bun/responsive.mjs} +18 -39
- package/bun/ssr.mjs +89 -0
- package/bun/theme-build.mjs +481 -0
- package/bun/theme-discovery.mjs +171 -0
- package/bun/watch.mjs +264 -0
- package/bun/wordpress.mjs +220 -0
- package/package.json +9 -17
- package/bun.lock +0 -1504
- package/webpack/base.mjs +0 -126
- package/webpack/helpers.mjs +0 -55
- package/webpack/index.mjs +0 -46
- package/webpack/production.mjs +0 -60
- package/webpack/project.mjs +0 -50
package/webpack/base.mjs
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Project Base overrides used in production and development build.
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import webpack from 'webpack';
|
|
7
|
-
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
8
|
-
import { WebpackManifestPlugin } from 'webpack-manifest-plugin';
|
|
9
|
-
import DependencyExtractionWebpackPlugin from '@wordpress/dependency-extraction-webpack-plugin';
|
|
10
|
-
import { esTwResponsiveCompiler } from './responsive-compiler.mjs';
|
|
11
|
-
|
|
12
|
-
export default (options) => {
|
|
13
|
-
// All Plugins used in production and development build.
|
|
14
|
-
const plugins = [];
|
|
15
|
-
|
|
16
|
-
// Provide variables to code build.
|
|
17
|
-
if (!options.overrides.includes('definePlugin')) {
|
|
18
|
-
plugins.push(
|
|
19
|
-
new webpack.DefinePlugin({
|
|
20
|
-
'process.env.VERSION': JSON.stringify(Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)),
|
|
21
|
-
'process.browser': true,
|
|
22
|
-
}),
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Output CSS from JS.
|
|
27
|
-
if (!options.overrides.includes('miniCssExtractPlugin')) {
|
|
28
|
-
plugins.push(
|
|
29
|
-
new MiniCssExtractPlugin({
|
|
30
|
-
filename: `${options.config.filesOutput}.css`,
|
|
31
|
-
}),
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Create manifest.json file.
|
|
36
|
-
if (!options.overrides.includes('webpackManifestPlugin')) {
|
|
37
|
-
plugins.push(new WebpackManifestPlugin());
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Enable export for all WordPress related packages
|
|
41
|
-
if (!options.overrides.includes('dependencyExtractionWebpackPlugin')) {
|
|
42
|
-
plugins.push(
|
|
43
|
-
new DependencyExtractionWebpackPlugin({
|
|
44
|
-
outputFormat: 'json',
|
|
45
|
-
}),
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Generate Tailwind manifest class sources before every build.
|
|
50
|
-
if (!options.overrides.includes('responsiveCompiler')) {
|
|
51
|
-
plugins.push(
|
|
52
|
-
esTwResponsiveCompiler({
|
|
53
|
-
projectDir: options.config.absolutePath,
|
|
54
|
-
breakpoints: options.tailwindBreakpoints,
|
|
55
|
-
}),
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// All module used in production and development build.
|
|
60
|
-
const module = {
|
|
61
|
-
rules: [],
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
// Module for JS and JSX.
|
|
65
|
-
if (!options.overrides.includes('js')) {
|
|
66
|
-
module.rules.push({
|
|
67
|
-
test: /\.(js|jsx)$/,
|
|
68
|
-
exclude: /node_modules[\\/](?!@eightshift)/,
|
|
69
|
-
use: {
|
|
70
|
-
loader: 'swc-loader',
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Module for MJS.
|
|
76
|
-
if (!options.overrides.includes('mjs')) {
|
|
77
|
-
module.rules.push({
|
|
78
|
-
test: /\.m?js/,
|
|
79
|
-
resolve: {
|
|
80
|
-
fullySpecified: false,
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Module for CSS.
|
|
86
|
-
if (!options.overrides.includes('css')) {
|
|
87
|
-
module.rules.push({
|
|
88
|
-
test: /\.css$/,
|
|
89
|
-
exclude: /node_modules/,
|
|
90
|
-
use: [MiniCssExtractPlugin.loader, 'css-loader', '@tailwindcss/webpack'],
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// Node modules - CSS.
|
|
94
|
-
module.rules.push({
|
|
95
|
-
test: /\.css$/,
|
|
96
|
-
include: /node_modules/,
|
|
97
|
-
use: [MiniCssExtractPlugin.loader, 'css-loader'],
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// Node modules - Eightshift package fonts.
|
|
101
|
-
module.rules.push({
|
|
102
|
-
test: /\.(woff2|ttf|otf)$/i,
|
|
103
|
-
type: 'asset/resource',
|
|
104
|
-
include: /node_modules\/@eightshift/,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Module for Images.
|
|
109
|
-
if (!options.overrides.includes('images')) {
|
|
110
|
-
module.rules.push({
|
|
111
|
-
test: /\.(png|svg|jpg|jpeg|gif|ico|webp)$/i,
|
|
112
|
-
exclude: [/fonts/, /node_modules/],
|
|
113
|
-
type: 'asset/resource',
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const resolve = {
|
|
118
|
-
symlinks: false,
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
plugins,
|
|
123
|
-
module,
|
|
124
|
-
resolve,
|
|
125
|
-
};
|
|
126
|
-
};
|
package/webpack/helpers.mjs
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File holding webpack helpers used to create project webpack build setup.
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import path from 'path';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Generate all paths required for Webpack build to work.
|
|
10
|
-
*
|
|
11
|
-
* @param {string} projectDir Current project directory absolute path.
|
|
12
|
-
* @param {string} projectPathConfig Project path relative to project root.
|
|
13
|
-
* @param {string} blocksAssetsPathConfig Path of the block assets.
|
|
14
|
-
* @param {string} outputPathConfig Public output path after projectPath location.
|
|
15
|
-
* @param {string} blocksManifestSettingsPath Main global settings manifest.json path after projectPath location.
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
|
-
function getConfig(projectDir, projectPathConfig, blocksAssetsPathConfig = 'src/Blocks/assets', outputPathConfig = 'public', blocksManifestSettingsPath = 'src/Blocks/manifest.json') {
|
|
19
|
-
if (typeof projectDir === 'undefined') {
|
|
20
|
-
throw Error('projectDir parameter is empty, please provide. This key represents: Current project directory absolute path. For example: __dirname');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (typeof projectPathConfig === 'undefined') {
|
|
24
|
-
throw Error('projectPath parameter is empty, please provide. This key represents: Project path relative to project root. For example: wp-content/themes/eightshift-boilerplate');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Clear all slashes from user config.
|
|
28
|
-
const projectPathConfigClean = projectPathConfig.replace(/^\/|\/$/g, '');
|
|
29
|
-
const blocksAssetsPathConfigClean = blocksAssetsPathConfig.replace(/^\/|\/$/g, '');
|
|
30
|
-
const outputPathConfigClean = outputPathConfig.replace(/^\/|\/$/g, '');
|
|
31
|
-
const blocksManifestSettingsPathClean = blocksManifestSettingsPath.replace(/^\/|\/$/g, '');
|
|
32
|
-
|
|
33
|
-
// Create absolute path from the projects relative path.
|
|
34
|
-
const absolutePath = `${projectDir}`;
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
absolutePath,
|
|
38
|
-
|
|
39
|
-
// Output files absolute location.
|
|
40
|
-
outputPath: path.resolve(absolutePath, outputPathConfigClean),
|
|
41
|
-
|
|
42
|
-
// Output files relative location, added before every output file in manifest.json. Should start and end with "/".
|
|
43
|
-
publicPath: path.join('/', projectPathConfigClean, outputPathConfigClean, '/'),
|
|
44
|
-
|
|
45
|
-
// Source files entries absolute locations.
|
|
46
|
-
applicationAdminEntry: path.resolve(absolutePath, blocksAssetsPathConfigClean, 'application-admin.js'),
|
|
47
|
-
applicationBlocksEntry: path.resolve(absolutePath, blocksAssetsPathConfigClean, 'application-blocks.js'),
|
|
48
|
-
applicationBlocksEditorEntry: path.resolve(absolutePath, blocksAssetsPathConfigClean, 'application-blocks-editor.js'),
|
|
49
|
-
applicationBlocksFrontendEntry: path.resolve(absolutePath, blocksAssetsPathConfigClean, 'application-blocks-frontend.js'),
|
|
50
|
-
|
|
51
|
-
blocksManifestSettingsPath: path.resolve(absolutePath, blocksManifestSettingsPathClean),
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export { getConfig };
|
package/webpack/index.mjs
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Main entrypoint location for webpack config.
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { merge } from 'webpack-merge';
|
|
7
|
-
import { getConfig } from './helpers.mjs';
|
|
8
|
-
import baseConfig from './base.mjs';
|
|
9
|
-
import projectConfig from './project.mjs';
|
|
10
|
-
import productionConfig from './production.mjs';
|
|
11
|
-
|
|
12
|
-
const eightshiftConfig = (mode, optionsData = {}) => {
|
|
13
|
-
// All config and default setting overrides must be provided using this object.
|
|
14
|
-
const options = {
|
|
15
|
-
config: {},
|
|
16
|
-
overrides: [],
|
|
17
|
-
tailwindBreakpoints: ['sm', 'md'],
|
|
18
|
-
...optionsData,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// Append project config using getConfig helper.
|
|
22
|
-
options.config = getConfig(optionsData.config.projectDir, optionsData.config.projectPath, optionsData.config.blocksAssetsPath, optionsData.config.outputPath, optionsData.config.blocksManifestSettingsPath);
|
|
23
|
-
|
|
24
|
-
options.config.mode = mode;
|
|
25
|
-
options.config.filesOutput = mode === 'production' ? '[name]-[contenthash]' : '[name]';
|
|
26
|
-
|
|
27
|
-
// Get all webpack partials.
|
|
28
|
-
const base = baseConfig(options);
|
|
29
|
-
const project = projectConfig(options);
|
|
30
|
-
const production = productionConfig(options);
|
|
31
|
-
|
|
32
|
-
// Default output that is going to be merged in any env.
|
|
33
|
-
const outputDefault = merge(project, base);
|
|
34
|
-
|
|
35
|
-
// Output development setup by default.
|
|
36
|
-
const development = {
|
|
37
|
-
devtool: false,
|
|
38
|
-
watchOptions: {
|
|
39
|
-
ignored: ['**/node_modules', '**/vendor', '**/public'],
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
return merge(outputDefault, mode === 'production' ? production : development);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export { eightshiftConfig };
|
package/webpack/production.mjs
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Project Production config used only in production build.
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import TerserPlugin from 'terser-webpack-plugin';
|
|
7
|
-
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
|
|
8
|
-
import { browserslistToTargets } from 'lightningcss';
|
|
9
|
-
import browserslist from 'browserslist';
|
|
10
|
-
|
|
11
|
-
export default (options) => {
|
|
12
|
-
// Enable Webpack caching for production
|
|
13
|
-
const cache = true;
|
|
14
|
-
|
|
15
|
-
// All Plugins used in production build.
|
|
16
|
-
const plugins = [];
|
|
17
|
-
|
|
18
|
-
// All Optimizations used in production build.
|
|
19
|
-
const optimization = {
|
|
20
|
-
minimize: true,
|
|
21
|
-
minimizer: [],
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// Plugin used to minify output.
|
|
25
|
-
if (!options.overrides.includes('terserPlugin')) {
|
|
26
|
-
optimization.minimizer.push(
|
|
27
|
-
new TerserPlugin({
|
|
28
|
-
parallel: true,
|
|
29
|
-
minify: TerserPlugin.swcMinify,
|
|
30
|
-
terserOptions: {
|
|
31
|
-
compress: {
|
|
32
|
-
drop_console: true,
|
|
33
|
-
passes: 2,
|
|
34
|
-
},
|
|
35
|
-
format: {
|
|
36
|
-
comments: false,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
}),
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (!options.overrides.includes('cssMinimizerPlugin')) {
|
|
44
|
-
optimization.minimizer.push(
|
|
45
|
-
new CssMinimizerPlugin({
|
|
46
|
-
parallel: true,
|
|
47
|
-
minify: CssMinimizerPlugin.lightningCssMinify,
|
|
48
|
-
minimizerOptions: {
|
|
49
|
-
targets: browserslistToTargets(browserslist('>= 0.25%')),
|
|
50
|
-
},
|
|
51
|
-
}),
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
plugins,
|
|
57
|
-
optimization,
|
|
58
|
-
cache,
|
|
59
|
-
};
|
|
60
|
-
};
|
package/webpack/project.mjs
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Project config used only in development and production build.
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import fs from 'fs';
|
|
7
|
-
|
|
8
|
-
export default (options) => {
|
|
9
|
-
const entry = {};
|
|
10
|
-
const output = {
|
|
11
|
-
path: options.config.outputPath,
|
|
12
|
-
publicPath: options.config.publicPath,
|
|
13
|
-
|
|
14
|
-
// This clean will remove the build folder on every start of the build process.
|
|
15
|
-
clean: true,
|
|
16
|
-
|
|
17
|
-
// If you are using the multiple webpack builds with dynamic import you must provide different name here in order to avoid collision.
|
|
18
|
-
library: '[name]',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// Load ApplicationAdmin Entrypoint.
|
|
22
|
-
if (!options.overrides.includes('applicationAdmin') && fs.existsSync(options.config.applicationAdminEntry)) {
|
|
23
|
-
entry.applicationAdmin = options.config.applicationAdminEntry;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Load ApplicationBlocks Entrypoint.
|
|
27
|
-
if (!options.overrides.includes('applicationBlocks') && fs.existsSync(options.config.applicationBlocksEntry)) {
|
|
28
|
-
entry.applicationBlocks = options.config.applicationBlocksEntry;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Load ApplicationBlocksEditor Entrypoint.
|
|
32
|
-
if (!options.overrides.includes('applicationBlocksEditor') && fs.existsSync(options.config.applicationBlocksEditorEntry)) {
|
|
33
|
-
entry.applicationBlocksEditor = options.config.applicationBlocksEditorEntry;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Load applicationBlocksFrontend Entrypoint.
|
|
37
|
-
if (!options.overrides.includes('applicationBlocksFrontend') && fs.existsSync(options.config.applicationBlocksFrontendEntry)) {
|
|
38
|
-
entry.applicationBlocksFrontend = options.config.applicationBlocksFrontendEntry;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Load filename Output.
|
|
42
|
-
if (!options.overrides.includes('filename')) {
|
|
43
|
-
output.filename = `${options.config.filesOutput}.js`;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
entry,
|
|
48
|
-
output,
|
|
49
|
-
};
|
|
50
|
-
};
|