eddev 0.2.65 → 0.2.67-beta1
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/admin/components/ImageWell.d.ts +2 -3
- package/admin/components/ImageWell.js +39 -51
- package/admin/defineField.d.ts +2 -2
- package/admin/defineWidget.d.ts +1 -1
- package/admin/defineWidget.js +2 -2
- package/admin/index.js +5 -1
- package/admin/installFieldTypes.js +26 -26
- package/admin/runWidgets.js +17 -28
- package/admin/selectMedia.d.ts +2 -2
- package/admin/selectMedia.js +1 -1
- package/blocks/ContentBlocks.d.ts +6 -6
- package/blocks/ContentBlocks.js +58 -66
- package/blocks/ErrorBoundaryEditor.d.ts +1 -1
- package/blocks/ErrorBoundaryEditor.js +16 -45
- package/blocks/ErrorBoundaryFrontend.d.ts +1 -1
- package/blocks/ErrorBoundaryFrontend.js +16 -45
- package/blocks/InspectorControls.d.ts +1 -1
- package/blocks/InspectorControls.js +3 -3
- package/blocks/blockAttributes.d.ts +2 -2
- package/blocks/blockAttributes.js +24 -44
- package/blocks/index.js +5 -1
- package/blocks/inlineEditing.d.ts +7 -7
- package/blocks/inlineEditing.js +36 -55
- package/blocks/installGutenbergHooks.js +48 -68
- package/build/babel/plugin-name-defined-components.js +15 -16
- package/build/build-favicon.js +11 -62
- package/build/clean.js +5 -52
- package/build/create-codegen-worker.js +78 -33
- package/build/create-serverless-dev-worker.js +61 -39
- package/build/create-webpack-worker.js +65 -33
- package/build/file-tree.d.ts +2 -2
- package/build/file-tree.js +12 -12
- package/build/get-webpack-config.js +341 -395
- package/build/graphql-codegen/graphql-codegen-files.js +31 -25
- package/build/graphql-codegen/graphql-codegen-no-duplicates.js +4 -4
- package/build/graphql-codegen/graphql-codegen-queries.js +102 -99
- package/build/manifests/manifest-blocks.d.ts +1 -1
- package/build/manifests/manifest-blocks.js +37 -29
- package/build/manifests/manifest-fields.d.ts +1 -1
- package/build/manifests/manifest-fields.js +23 -21
- package/build/manifests/manifest-views.d.ts +1 -1
- package/build/manifests/manifest-views.js +32 -25
- package/build/manifests/manifest-widgets.d.ts +1 -1
- package/build/manifests/manifest-widgets.js +22 -20
- package/build/manifests/manifest.d.ts +2 -2
- package/build/manifests/manifest.js +30 -90
- package/build/reporter.d.ts +1 -1
- package/build/reporter.js +29 -32
- package/build/serverless/create-next-app.d.ts +1 -1
- package/build/serverless/create-next-app.js +245 -467
- package/build/state/codegen-state.d.ts +4 -4
- package/build/state/compiler-state.d.ts +5 -5
- package/build/state/serverless-state.d.ts +3 -3
- package/build/workers/codegen-worker-script.js +392 -507
- package/build/workers/serverless-worker-dev-script.js +4 -4
- package/build/workers/webpack-worker-script.js +89 -150
- package/cli/build.dev.d.ts +1 -1
- package/cli/build.dev.js +79 -126
- package/cli/build.prod.d.ts +1 -1
- package/cli/build.prod.js +42 -98
- package/cli/cli.js +16 -55
- package/cli/display/components/BundleDisplay.d.ts +1 -2
- package/cli/display/components/BundleDisplay.js +13 -24
- package/cli/display/components/CodegenDisplay.d.ts +1 -2
- package/cli/display/components/CodegenDisplay.js +14 -25
- package/cli/display/components/DevCLIDisplay.d.ts +2 -3
- package/cli/display/components/DevCLIDisplay.js +14 -25
- package/cli/display/components/Fullscreen.js +9 -20
- package/cli/display/components/ServerlessDisplay.d.ts +2 -3
- package/cli/display/components/ServerlessDisplay.js +15 -26
- package/cli/display/components/StatusIcon.d.ts +2 -3
- package/cli/display/components/StatusIcon.js +3 -3
- package/cli/preinstall.js +4 -5
- package/cli/setup.js +25 -73
- package/components/AdminBar.d.ts +1 -2
- package/components/AdminBar.js +37 -3
- package/components/BrowserRouter.d.ts +2 -2
- package/components/BrowserRouter.js +41 -54
- package/components/InlinePage.d.ts +2 -2
- package/components/InlinePage.js +17 -29
- package/components/NextRouter.d.ts +2 -2
- package/components/NextRouter.js +20 -29
- package/components/index.js +5 -1
- package/config/config-schema.d.ts +1 -1
- package/config/config-schema.js +1 -1
- package/config/create-schema-file.js +6 -6
- package/config/get-config.js +10 -13
- package/config/index.js +5 -1
- package/config/parse-config.js +1 -1
- package/config/print-zod-errors.js +3 -3
- package/dev-ui/components/BreakpointColumnHeader.d.ts +2 -3
- package/dev-ui/components/BreakpointColumnHeader.js +7 -18
- package/dev-ui/components/BreakpointIndicator.d.ts +1 -2
- package/dev-ui/components/BreakpointIndicator.js +25 -32
- package/dev-ui/components/DevUI.d.ts +1 -2
- package/dev-ui/components/DevUI.js +13 -13
- package/dev-ui/components/Launcher.d.ts +2 -2
- package/dev-ui/components/Launcher.js +13 -25
- package/dev-ui/components/PanelWrapper.d.ts +2 -2
- package/dev-ui/components/PanelWrapper.js +8 -8
- package/dev-ui/components/ResponsiveLerpControl.d.ts +2 -3
- package/dev-ui/components/ResponsiveLerpControl.js +27 -38
- package/dev-ui/components/ResponsiveScaleEditor.d.ts +4 -5
- package/dev-ui/components/ResponsiveScaleEditor.js +64 -78
- package/dev-ui/components/atoms/Button.js +1 -1
- package/dev-ui/components/atoms/Dropdown.d.ts +3 -3
- package/dev-ui/components/atoms/Dropdown.js +8 -9
- package/dev-ui/components/atoms/NumberField.d.ts +2 -3
- package/dev-ui/components/atoms/NumberField.js +29 -42
- package/dev-ui/components/atoms/Spacer.js +1 -1
- package/dev-ui/components/atoms/Text.js +1 -1
- package/dev-ui/components/atoms/ToggleButton.d.ts +2 -2
- package/dev-ui/components/atoms/ToggleButton.js +5 -16
- package/dev-ui/components/atoms/Tooltip.d.ts +2 -2
- package/dev-ui/components/atoms/Tooltip.js +8 -20
- package/dev-ui/components/panels/AppDataDebugger.d.ts +1 -2
- package/dev-ui/components/panels/AppDataDebugger.js +8 -19
- package/dev-ui/components/panels/ColorEditor.d.ts +1 -2
- package/dev-ui/components/panels/ColorEditor.js +35 -42
- package/dev-ui/components/panels/PageDataDebugger.d.ts +1 -2
- package/dev-ui/components/panels/PageDataDebugger.js +8 -20
- package/dev-ui/components/panels/QueryDebugger.d.ts +1 -2
- package/dev-ui/components/panels/QueryDebugger.js +12 -24
- package/dev-ui/components/panels/SpacingEditor.d.ts +1 -2
- package/dev-ui/components/panels/SpacingEditor.js +34 -48
- package/dev-ui/components/panels/TypographyEditor.d.ts +1 -2
- package/dev-ui/components/panels/TypographyEditor.js +38 -46
- package/dev-ui/hooks/useBreakpoint.d.ts +1 -1
- package/dev-ui/hooks/useBreakpoint.js +13 -13
- package/dev-ui/hooks/usePersistState.js +6 -7
- package/dev-ui/hooks/useStylesheet.js +6 -6
- package/dev-ui/icons.d.ts +15 -16
- package/dev-ui/icons.js +16 -27
- package/dev-ui/index.js +5 -1
- package/dev-ui/loader.d.ts +1 -2
- package/dev-ui/loader.js +13 -9
- package/dev-ui/panels.d.ts +2 -2
- package/dev-ui/panels.js +7 -7
- package/dev-ui/theme.d.ts +96 -70
- package/dev-ui/theme.js +3 -3
- package/dynamic/dynamic-component.d.ts +1 -10
- package/dynamic/dynamic-component.js +1 -1
- package/dynamic/index.js +5 -1
- package/entry/Root.d.ts +2 -3
- package/entry/Root.js +16 -26
- package/entry/entry.admin.dev.js +4 -4
- package/entry/entry.admin.prod.js +4 -4
- package/entry/entry.monolith.dev.js +5 -5
- package/entry/entry.monolith.prod.js +5 -5
- package/gravityforms/gravity-forms.d.ts +2 -2
- package/gravityforms/index.js +5 -1
- package/gravityforms/useGravityForm.d.ts +2 -2
- package/gravityforms/useGravityForm.js +126 -130
- package/hooks/index.js +5 -1
- package/hooks/queryUtils.d.ts +14 -14
- package/hooks/queryUtils.js +101 -192
- package/hooks/useAppData.d.ts +2 -2
- package/hooks/useAppData.js +9 -9
- package/hooks/usePageLoad.js +4 -4
- package/hooks/useQueryDebug.d.ts +1 -1
- package/hooks/useQueryDebug.js +7 -7
- package/hooks/useRPC.d.ts +4 -4
- package/hooks/useRPC.js +3 -3
- package/package.json +7 -7
- package/routing/index.js +5 -1
- package/routing/remoteProps.d.ts +1 -1
- package/routing/remoteProps.js +31 -72
- package/routing/routing.d.ts +15 -15
- package/routing/routing.js +108 -170
- package/routing/updateEditLink.js +1 -1
- package/serverless/define-api.d.ts +1 -1
- package/serverless/define-rpc-router.js +8 -4
- package/serverless/index.js +6 -2
- package/serverless-template/_utils/fetch-wordpress-props.ts +0 -4
- package/serverless-template/_utils/fetch-wp.ts +0 -1
- package/style/createStitches.d.ts +375 -783
- package/style/createStitches.js +164 -142
- package/style/index.js +5 -1
- package/tsconfig.json +1 -1
- package/utils/Observable.d.ts +2 -2
- package/utils/Observable.js +12 -15
- package/utils/getRepoName.js +3 -3
- package/utils/promptIfRepoNameIncorrect.js +18 -64
- package/utils/refreshOverlayInterop.js +1 -1
- package/utils/reportErrorStack.d.ts +1 -1
- package/utils/reportErrorStack.js +1 -1
- package/utils/serverlessAppContext.js +1 -1
- package/utils/updateEnvFile.js +19 -69
- package/utils/useObservable.js +3 -3
- package/views/index.js +5 -1
|
@@ -1,414 +1,360 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
-
if (ar || !(i in from)) {
|
|
52
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
-
ar[i] = from[i];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
-
};
|
|
58
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
59
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
4
|
};
|
|
61
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
6
|
+
const webpack_1 = require("webpack");
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
9
|
+
const webpack_virtual_modules_1 = __importDefault(require("webpack-virtual-modules"));
|
|
66
10
|
// @ts-ignore
|
|
67
|
-
|
|
11
|
+
const friendly_errors_webpack_plugin_1 = __importDefault(require("@soda/friendly-errors-webpack-plugin"));
|
|
68
12
|
// @ts-ignore
|
|
69
|
-
|
|
13
|
+
const webpack_plugin_1 = __importDefault(require("@loadable/webpack-plugin"));
|
|
70
14
|
// @ts-ignore
|
|
71
|
-
|
|
15
|
+
const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
|
|
72
16
|
// @ts-ignore
|
|
73
|
-
|
|
74
|
-
|
|
17
|
+
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
18
|
+
const autoprefixer_1 = __importDefault(require("autoprefixer"));
|
|
75
19
|
// Custom Babel plugins
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
function getWebpackConfig(opts) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
20
|
+
const plugin_name_defined_components_1 = __importDefault(require("./babel/plugin-name-defined-components"));
|
|
21
|
+
const fs_1 = require("fs");
|
|
22
|
+
const manifest_blocks_1 = require("./manifests/manifest-blocks");
|
|
23
|
+
const manifest_fields_1 = require("./manifests/manifest-fields");
|
|
24
|
+
const manifest_views_1 = require("./manifests/manifest-views");
|
|
25
|
+
const get_config_1 = require("../config/get-config");
|
|
26
|
+
const manifest_widgets_1 = require("./manifests/manifest-widgets");
|
|
27
|
+
async function getWebpackConfig(opts) {
|
|
28
|
+
let compiling = false;
|
|
29
|
+
const config = (0, get_config_1.getEDConfigUnwrapped)();
|
|
30
|
+
// Webpack config
|
|
31
|
+
const ALIAS = {};
|
|
32
|
+
const ENTRY = {};
|
|
33
|
+
const PLUGINS = [];
|
|
34
|
+
const RULES = [];
|
|
35
|
+
const DEFINES = {};
|
|
36
|
+
const VIRTUAL_MODULES = {};
|
|
37
|
+
const EXTERNALS = {};
|
|
38
|
+
// Initialize the virtual modules plugin
|
|
39
|
+
let virtualModules;
|
|
40
|
+
// Helpful calculations
|
|
41
|
+
const isServerless = opts.serverless;
|
|
42
|
+
const isBrowser = opts.target === "client";
|
|
43
|
+
const isSSR = isServerless && !isBrowser;
|
|
44
|
+
const isDev = opts.mode === "development";
|
|
45
|
+
// Entry points
|
|
46
|
+
const entryDir = path_1.default.resolve(path_1.default.dirname(__dirname), "./entry");
|
|
47
|
+
if (isDev) {
|
|
48
|
+
if (opts.isAdmin) {
|
|
49
|
+
ENTRY["main"] = [`${entryDir}/entry.publicPath.js`, `${entryDir}/entry.admin.dev.js`];
|
|
50
|
+
}
|
|
51
|
+
else if (isServerless) {
|
|
52
|
+
ENTRY["main"] = [`${entryDir}/entry.serverless.dev.js`];
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
ENTRY["main"] = [`${entryDir}/entry.publicPath.js`, `${entryDir}/entry.monolith.dev.js`];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
if (opts.isAdmin) {
|
|
60
|
+
ENTRY["main"] = [`${entryDir}/entry.publicPath.js`, `${entryDir}/entry.admin.prod.js`];
|
|
61
|
+
}
|
|
62
|
+
else if (isServerless) {
|
|
63
|
+
ENTRY["main"] = [`${entryDir}/entry.serverless.prod.js`];
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
ENTRY["main"] = [`${entryDir}/entry.publicPath.js`, `${entryDir}/entry.monolith.prod.js`];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Admin entry
|
|
70
|
+
// Determine output file placement
|
|
71
|
+
const distSuffix = opts.isAdmin ? "admin" : "frontend";
|
|
72
|
+
const outputFolder = path_1.default.resolve(opts.baseDirectory, isServerless ? (isDev ? "./.edwp/dev" : "./.edwp/prod") : "./dist/" + distSuffix);
|
|
73
|
+
const loadableManifestFile = `loadable-stats.json`;
|
|
74
|
+
// JS/TS
|
|
75
|
+
ALIAS["@blocks"] = path_1.default.join(opts.baseDirectory, "blocks");
|
|
76
|
+
ALIAS["@components"] = path_1.default.join(opts.baseDirectory, "components");
|
|
77
|
+
ALIAS["@views"] = path_1.default.join(opts.baseDirectory, "views");
|
|
78
|
+
ALIAS["@hooks"] = path_1.default.join(opts.baseDirectory, "hooks");
|
|
79
|
+
ALIAS["@lib"] = path_1.default.join(opts.baseDirectory, "lib");
|
|
80
|
+
ALIAS["@queries"] = path_1.default.join(opts.baseDirectory, "hooks/queries");
|
|
81
|
+
ALIAS["@utils"] = path_1.default.join(opts.baseDirectory, "utils");
|
|
82
|
+
RULES.push({
|
|
83
|
+
test: /\.[jt]sx?$/,
|
|
84
|
+
exclude: /node_modules/,
|
|
85
|
+
use: [
|
|
86
|
+
{
|
|
87
|
+
loader: require.resolve("babel-loader"),
|
|
88
|
+
options: {
|
|
89
|
+
presets: [
|
|
90
|
+
[
|
|
91
|
+
require.resolve("@babel/preset-env"),
|
|
140
92
|
{
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
require.resolve("@babel/preset-env"),
|
|
146
|
-
{
|
|
147
|
-
useBuiltIns: "entry",
|
|
148
|
-
exclude: ["@babel/plugin-transform-regenerator"],
|
|
149
|
-
targets: "> 0.25%, not dead",
|
|
150
|
-
corejs: 3,
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
[
|
|
154
|
-
require.resolve("@babel/preset-react"),
|
|
155
|
-
{
|
|
156
|
-
runtime: "automatic",
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
require.resolve("@babel/preset-typescript"),
|
|
160
|
-
],
|
|
161
|
-
plugins: [
|
|
162
|
-
[plugin_name_defined_components_1.default, { baseDirectory: opts.baseDirectory, cool: true }],
|
|
163
|
-
isBrowser && isDev && !opts.isAdmin && [require.resolve("react-refresh/babel"), { skipEnvCheck: true }],
|
|
164
|
-
require.resolve("@loadable/babel-plugin"),
|
|
165
|
-
].filter(Boolean),
|
|
166
|
-
},
|
|
93
|
+
useBuiltIns: "entry",
|
|
94
|
+
exclude: ["@babel/plugin-transform-regenerator"],
|
|
95
|
+
targets: "> 0.25%, not dead",
|
|
96
|
+
corejs: 3,
|
|
167
97
|
},
|
|
168
98
|
],
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
ALIAS["@styles"] = path_1.default.join(opts.baseDirectory, "styles");
|
|
172
|
-
ALIAS["@theme"] = path_1.default.join(opts.baseDirectory, "theme.css.tsx");
|
|
173
|
-
PLUGINS.push(new mini_css_extract_plugin_1.default());
|
|
174
|
-
RULES.push({
|
|
175
|
-
test: /\.(sa|sc|c)ss$/,
|
|
176
|
-
use: [
|
|
177
|
-
{
|
|
178
|
-
loader: mini_css_extract_plugin_1.default.loader,
|
|
179
|
-
options: {
|
|
180
|
-
publicPath: "/wp-content/themes/".concat(opts.themeName, "/dist/").concat(distSuffix),
|
|
181
|
-
},
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
loader: require.resolve("css-loader"),
|
|
185
|
-
options: {
|
|
186
|
-
import: true,
|
|
187
|
-
// sourceMap: true,
|
|
188
|
-
importLoaders: 2,
|
|
189
|
-
// modules: true,
|
|
190
|
-
},
|
|
191
|
-
},
|
|
99
|
+
[
|
|
100
|
+
require.resolve("@babel/preset-react"),
|
|
192
101
|
{
|
|
193
|
-
|
|
194
|
-
options: {
|
|
195
|
-
postcssOptions: {
|
|
196
|
-
ident: "postcss",
|
|
197
|
-
sourceMap: true,
|
|
198
|
-
plugins: [(0, autoprefixer_1.default)()],
|
|
199
|
-
},
|
|
200
|
-
},
|
|
102
|
+
runtime: "automatic",
|
|
201
103
|
},
|
|
202
104
|
],
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (isBrowser && isDev && !opts.isAdmin) {
|
|
214
|
-
PLUGINS.push(new react_refresh_webpack_plugin_1.default({
|
|
215
|
-
overlay: {
|
|
216
|
-
// module: require.resolve("../utils/refreshOverlayInterop"),
|
|
217
|
-
// @ts-ignore
|
|
218
|
-
// sockProtocol: "http",
|
|
219
|
-
sockHost: "127.0.0.1",
|
|
220
|
-
sockPort: opts.hotPort,
|
|
221
|
-
sockIntegration: "wds",
|
|
222
|
-
},
|
|
223
|
-
}));
|
|
224
|
-
}
|
|
225
|
-
// Loadable plugin for code-splitting
|
|
226
|
-
if (isBrowser)
|
|
227
|
-
PLUGINS.push(new webpack_plugin_1.default({
|
|
228
|
-
filename: loadableManifestFile,
|
|
229
|
-
writeToDisk: true,
|
|
230
|
-
}));
|
|
231
|
-
// Predefined values, good data injection
|
|
232
|
-
PLUGINS.push(new webpack_1.DefinePlugin(DEFINES));
|
|
233
|
-
// Errors
|
|
234
|
-
if (!isDev) {
|
|
235
|
-
PLUGINS.push(new friendly_errors_webpack_plugin_1.default({
|
|
236
|
-
clearConsole: false,
|
|
237
|
-
}));
|
|
238
|
-
}
|
|
239
|
-
if (isDev) {
|
|
240
|
-
// PLUGINS.push(new ErrorOverlayPlugin())
|
|
241
|
-
}
|
|
242
|
-
// Virtual modules, for code injection
|
|
243
|
-
virtualModules = new webpack_virtual_modules_1.default(VIRTUAL_MODULES);
|
|
244
|
-
PLUGINS.push(virtualModules);
|
|
245
|
-
writeVirtualModule = function (name, contents) {
|
|
246
|
-
if (compiling) {
|
|
247
|
-
virtualModules.writeModule(name, contents);
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
VIRTUAL_MODULES[name] = contents;
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
manifestLoaders = [];
|
|
254
|
-
// Views
|
|
255
|
-
ALIAS["@manifest/views"] = path_1.default.resolve(opts.baseDirectory, "_view_manifest.js");
|
|
256
|
-
if (opts.isAdmin) {
|
|
257
|
-
writeVirtualModule(ALIAS["@manifest/views"], "export default {}");
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
manifestLoaders.push((0, manifest_views_1.createViewManifestGenerator)({
|
|
261
|
-
baseDirectory: opts.baseDirectory,
|
|
262
|
-
isAdmin: false,
|
|
263
|
-
isDev: isDev,
|
|
264
|
-
isServerless: isServerless,
|
|
265
|
-
watch: isDev,
|
|
266
|
-
onGenerate: function (manifest) {
|
|
267
|
-
writeVirtualModule(ALIAS["@manifest/views"], manifest);
|
|
268
|
-
},
|
|
269
|
-
}));
|
|
270
|
-
}
|
|
271
|
-
// Field manifest
|
|
272
|
-
ALIAS["@manifest/fields"] = path_1.default.resolve(opts.baseDirectory, "_fields_manifest.js");
|
|
273
|
-
if (opts.isAdmin) {
|
|
274
|
-
manifestLoaders.push((0, manifest_fields_1.createFieldManifestGenerator)({
|
|
275
|
-
baseDirectory: opts.baseDirectory,
|
|
276
|
-
isAdmin: true,
|
|
277
|
-
isDev: isDev,
|
|
278
|
-
isServerless: isServerless,
|
|
279
|
-
watch: isDev,
|
|
280
|
-
onGenerate: function (manifest) {
|
|
281
|
-
writeVirtualModule(ALIAS["@manifest/fields"], manifest);
|
|
282
|
-
},
|
|
283
|
-
}));
|
|
284
|
-
}
|
|
285
|
-
else {
|
|
286
|
-
writeVirtualModule(ALIAS["@manifest/fields"], "\n export default {}\n ");
|
|
287
|
-
}
|
|
288
|
-
// Field manifest
|
|
289
|
-
ALIAS["@manifest/widgets"] = path_1.default.resolve(opts.baseDirectory, "_widgets_manifest.js");
|
|
290
|
-
if (opts.isAdmin) {
|
|
291
|
-
manifestLoaders.push((0, manifest_widgets_1.createWidgetManifestGenerator)({
|
|
292
|
-
baseDirectory: opts.baseDirectory,
|
|
293
|
-
isAdmin: true,
|
|
294
|
-
isDev: isDev,
|
|
295
|
-
isServerless: isServerless,
|
|
296
|
-
watch: isDev,
|
|
297
|
-
onGenerate: function (manifest) {
|
|
298
|
-
writeVirtualModule(ALIAS["@manifest/widgets"], manifest);
|
|
299
|
-
},
|
|
300
|
-
}));
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
writeVirtualModule(ALIAS["@manifest/widgets"], "\n export default {}\n ");
|
|
304
|
-
}
|
|
305
|
-
// Block manifest
|
|
306
|
-
ALIAS["@manifest/blocks"] = path_1.default.resolve(opts.baseDirectory, "_blocks_manifest.js");
|
|
307
|
-
manifestLoaders.push((0, manifest_blocks_1.createBlockManifestGenerator)({
|
|
308
|
-
baseDirectory: opts.baseDirectory,
|
|
309
|
-
isAdmin: opts.isAdmin,
|
|
310
|
-
isDev: isDev,
|
|
311
|
-
isServerless: isServerless,
|
|
312
|
-
watch: isDev,
|
|
313
|
-
onGenerate: function (manifest) {
|
|
314
|
-
writeVirtualModule(ALIAS["@manifest/blocks"], manifest);
|
|
315
|
-
},
|
|
316
|
-
}));
|
|
317
|
-
// Wait for all manifests to resolve
|
|
318
|
-
return [4 /*yield*/, Promise.all(manifestLoaders)
|
|
319
|
-
// External Gutenberg
|
|
320
|
-
];
|
|
321
|
-
case 1:
|
|
322
|
-
// Wait for all manifests to resolve
|
|
323
|
-
_a.sent();
|
|
324
|
-
// External Gutenberg
|
|
325
|
-
EXTERNALS["@wordpress/components"] = ["window", "wp"];
|
|
326
|
-
EXTERNALS["@wordpress/element"] = ["window", "wp"];
|
|
327
|
-
EXTERNALS["@wordpress/blocks"] = ["window", "wp"];
|
|
328
|
-
EXTERNALS["@wordpress/utils"] = ["window", "wp"];
|
|
329
|
-
EXTERNALS["@wordpress/data"] = ["window", "wp"];
|
|
330
|
-
EXTERNALS["@wordpress/hooks"] = ["window", "wp"];
|
|
331
|
-
EXTERNALS["@wordpress/block-editor"] = ["window", "wp"];
|
|
332
|
-
if (opts.isAdmin) {
|
|
333
|
-
EXTERNALS["@wordpress/components"] = ["wp", "components"];
|
|
334
|
-
EXTERNALS["@wordpress/element"] = ["wp", "element"];
|
|
335
|
-
EXTERNALS["@wordpress/blocks"] = ["wp", "blocks"];
|
|
336
|
-
EXTERNALS["@wordpress/utils"] = ["wp", "utils"];
|
|
337
|
-
EXTERNALS["@wordpress/data"] = ["wp", "data"];
|
|
338
|
-
EXTERNALS["@wordpress/hooks"] = ["wp", "hooks"];
|
|
339
|
-
EXTERNALS["@wordpress/block-editor"] = ["wp", "blockEditor"];
|
|
340
|
-
EXTERNALS["react"] = "React";
|
|
341
|
-
EXTERNALS["react-dom"] = "ReactDOM";
|
|
342
|
-
}
|
|
343
|
-
// Define some values
|
|
344
|
-
DEFINES["process.browser"] = JSON.stringify(isBrowser);
|
|
345
|
-
DEFINES["process.client"] = JSON.stringify(isBrowser);
|
|
346
|
-
DEFINES["process.serverless"] = "false";
|
|
347
|
-
DEFINES["process.ssr"] = JSON.stringify(isServerless && !isBrowser);
|
|
348
|
-
DEFINES["process.LOADABLE_STATS_FILE"] = JSON.stringify(loadableManifestFile);
|
|
349
|
-
DEFINES["process.dev"] = isDev ? "true" : "false";
|
|
350
|
-
DEFINES["process.admin"] = opts.isAdmin ? "true" : "false";
|
|
351
|
-
DEFINES["process.env.themePath"] = JSON.stringify("/wp-content/themes/".concat(opts.themeName));
|
|
352
|
-
DEFINES["process.themePath"] = JSON.stringify("/wp-content/themes/".concat(opts.themeName));
|
|
353
|
-
if (isDev && opts.isAdmin) {
|
|
354
|
-
DEFINES["process.BLOCK_MANIFEST_FILE"] = JSON.stringify(ALIAS["@manifest/blocks"]);
|
|
355
|
-
}
|
|
356
|
-
DEFINES["process.devUI"] = config.devUI === "enabled";
|
|
357
|
-
DEFINES["process.serverlessEndpoint"] = "(window.SERVERLESS_ENDPOINT || '')";
|
|
358
|
-
rpcExists = (0, fs_1.existsSync)(path_1.default.join(opts.baseDirectory, "apis/_rpc.ts")) ||
|
|
359
|
-
(0, fs_1.existsSync)(path_1.default.join(opts.baseDirectory, "apis/_rpc/index.ts"));
|
|
360
|
-
DEFINES["process.rpcEnabled"] = rpcExists ? "true" : "false";
|
|
361
|
-
if (isBrowser) {
|
|
362
|
-
DEFINES["process.env.themePath"] = "window.THEME_PATH || ".concat(DEFINES["process.env.themePath"]);
|
|
363
|
-
}
|
|
364
|
-
buildID = Date.now();
|
|
365
|
-
return [2 /*return*/, {
|
|
366
|
-
mode: opts.mode,
|
|
367
|
-
context: opts.baseDirectory,
|
|
368
|
-
target: opts.target === "ssr" ? "node" : "web",
|
|
369
|
-
optimization: {
|
|
370
|
-
splitChunks: {
|
|
371
|
-
chunks: "async",
|
|
372
|
-
},
|
|
373
|
-
minimize: opts.mode === "production",
|
|
374
|
-
// chunkIds: "named",
|
|
375
|
-
},
|
|
376
|
-
output: {
|
|
377
|
-
filename: "[name].".concat(opts.isAdmin ? "admin" : "frontend", ".js?v=").concat(buildID),
|
|
378
|
-
chunkFilename: "[name].".concat(opts.isAdmin ? "admin" : "frontend", ".js?v=").concat(buildID),
|
|
379
|
-
publicPath: "/wp-content/themes/".concat(opts.themeName, "/dist/").concat(distSuffix, "/"),
|
|
380
|
-
path: outputFolder,
|
|
381
|
-
globalObject: isSSR ? "this" : "self",
|
|
382
|
-
clean: true,
|
|
383
|
-
},
|
|
384
|
-
externals: __assign({ worker_threads: true }, EXTERNALS),
|
|
385
|
-
resolve: {
|
|
386
|
-
alias: ALIAS,
|
|
387
|
-
extensions: [".js", ".jsx", ".ts", ".tsx"],
|
|
388
|
-
},
|
|
389
|
-
entry: ENTRY,
|
|
390
|
-
plugins: __spreadArray(__spreadArray([], PLUGINS, true), [
|
|
391
|
-
function () {
|
|
392
|
-
compiling = true;
|
|
393
|
-
},
|
|
394
|
-
], false),
|
|
395
|
-
module: {
|
|
396
|
-
rules: RULES,
|
|
397
|
-
},
|
|
398
|
-
devtool: opts.mode === "development" && opts.target === "client"
|
|
399
|
-
? opts.mode === "development"
|
|
400
|
-
? "cheap-module-source-map"
|
|
401
|
-
: "source-map"
|
|
402
|
-
: false,
|
|
403
|
-
stats: {
|
|
404
|
-
all: true,
|
|
405
|
-
errorDetails: true,
|
|
406
|
-
errors: true,
|
|
407
|
-
colors: true,
|
|
408
|
-
},
|
|
409
|
-
}];
|
|
410
|
-
}
|
|
411
|
-
});
|
|
105
|
+
require.resolve("@babel/preset-typescript"),
|
|
106
|
+
],
|
|
107
|
+
plugins: [
|
|
108
|
+
[plugin_name_defined_components_1.default, { baseDirectory: opts.baseDirectory, cool: true }],
|
|
109
|
+
isBrowser && isDev && !opts.isAdmin && [require.resolve("react-refresh/babel"), { skipEnvCheck: true }],
|
|
110
|
+
require.resolve("@loadable/babel-plugin"),
|
|
111
|
+
].filter(Boolean),
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
],
|
|
412
115
|
});
|
|
116
|
+
// Styling
|
|
117
|
+
ALIAS["@styles"] = path_1.default.join(opts.baseDirectory, "styles");
|
|
118
|
+
ALIAS["@theme"] = path_1.default.join(opts.baseDirectory, "theme.css.tsx");
|
|
119
|
+
PLUGINS.push(new mini_css_extract_plugin_1.default());
|
|
120
|
+
RULES.push({
|
|
121
|
+
test: /\.(sa|sc|c)ss$/,
|
|
122
|
+
use: [
|
|
123
|
+
{
|
|
124
|
+
loader: mini_css_extract_plugin_1.default.loader,
|
|
125
|
+
options: {
|
|
126
|
+
publicPath: `/wp-content/themes/${opts.themeName}/dist/${distSuffix}`,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
loader: require.resolve("css-loader"),
|
|
131
|
+
options: {
|
|
132
|
+
import: true,
|
|
133
|
+
// sourceMap: true,
|
|
134
|
+
importLoaders: 2,
|
|
135
|
+
// modules: true,
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
loader: require.resolve("postcss-loader"),
|
|
140
|
+
options: {
|
|
141
|
+
postcssOptions: {
|
|
142
|
+
ident: "postcss",
|
|
143
|
+
sourceMap: true,
|
|
144
|
+
plugins: [(0, autoprefixer_1.default)()],
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
});
|
|
150
|
+
// Bundle analyser
|
|
151
|
+
if (!opts.isAdmin && !isDev) {
|
|
152
|
+
PLUGINS.push(new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({
|
|
153
|
+
analyzerMode: "static",
|
|
154
|
+
openAnalyzer: false,
|
|
155
|
+
reportFilename: "./bundle-report.html",
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
// React Refresh
|
|
159
|
+
if (isBrowser && isDev && !opts.isAdmin) {
|
|
160
|
+
PLUGINS.push(new react_refresh_webpack_plugin_1.default({
|
|
161
|
+
overlay: {
|
|
162
|
+
// module: require.resolve("../utils/refreshOverlayInterop"),
|
|
163
|
+
// @ts-ignore
|
|
164
|
+
// sockProtocol: "http",
|
|
165
|
+
sockHost: "127.0.0.1",
|
|
166
|
+
sockPort: opts.hotPort,
|
|
167
|
+
sockIntegration: "wds",
|
|
168
|
+
},
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
// Loadable plugin for code-splitting
|
|
172
|
+
if (isBrowser)
|
|
173
|
+
PLUGINS.push(new webpack_plugin_1.default({
|
|
174
|
+
filename: loadableManifestFile,
|
|
175
|
+
writeToDisk: true,
|
|
176
|
+
}));
|
|
177
|
+
// Predefined values, good data injection
|
|
178
|
+
PLUGINS.push(new webpack_1.DefinePlugin(DEFINES));
|
|
179
|
+
// Errors
|
|
180
|
+
if (!isDev) {
|
|
181
|
+
PLUGINS.push(new friendly_errors_webpack_plugin_1.default({
|
|
182
|
+
clearConsole: false,
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
if (isDev) {
|
|
186
|
+
// PLUGINS.push(new ErrorOverlayPlugin())
|
|
187
|
+
}
|
|
188
|
+
// Virtual modules, for code injection
|
|
189
|
+
virtualModules = new webpack_virtual_modules_1.default(VIRTUAL_MODULES);
|
|
190
|
+
PLUGINS.push(virtualModules);
|
|
191
|
+
const writeVirtualModule = (name, contents) => {
|
|
192
|
+
if (compiling) {
|
|
193
|
+
virtualModules.writeModule(name, contents);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
VIRTUAL_MODULES[name] = contents;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const manifestLoaders = [];
|
|
200
|
+
// Views
|
|
201
|
+
ALIAS["@manifest/views"] = path_1.default.resolve(opts.baseDirectory, "_view_manifest.js");
|
|
202
|
+
if (opts.isAdmin) {
|
|
203
|
+
writeVirtualModule(ALIAS["@manifest/views"], `export default {}`);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
manifestLoaders.push((0, manifest_views_1.createViewManifestGenerator)({
|
|
207
|
+
baseDirectory: opts.baseDirectory,
|
|
208
|
+
isAdmin: false,
|
|
209
|
+
isDev: isDev,
|
|
210
|
+
isServerless: isServerless,
|
|
211
|
+
watch: isDev,
|
|
212
|
+
onGenerate: (manifest) => {
|
|
213
|
+
writeVirtualModule(ALIAS["@manifest/views"], manifest);
|
|
214
|
+
},
|
|
215
|
+
}));
|
|
216
|
+
}
|
|
217
|
+
// Field manifest
|
|
218
|
+
ALIAS["@manifest/fields"] = path_1.default.resolve(opts.baseDirectory, "_fields_manifest.js");
|
|
219
|
+
if (opts.isAdmin) {
|
|
220
|
+
manifestLoaders.push((0, manifest_fields_1.createFieldManifestGenerator)({
|
|
221
|
+
baseDirectory: opts.baseDirectory,
|
|
222
|
+
isAdmin: true,
|
|
223
|
+
isDev: isDev,
|
|
224
|
+
isServerless: isServerless,
|
|
225
|
+
watch: isDev,
|
|
226
|
+
onGenerate: (manifest) => {
|
|
227
|
+
writeVirtualModule(ALIAS["@manifest/fields"], manifest);
|
|
228
|
+
},
|
|
229
|
+
}));
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
writeVirtualModule(ALIAS["@manifest/fields"], `
|
|
233
|
+
export default {}
|
|
234
|
+
`);
|
|
235
|
+
}
|
|
236
|
+
// Field manifest
|
|
237
|
+
ALIAS["@manifest/widgets"] = path_1.default.resolve(opts.baseDirectory, "_widgets_manifest.js");
|
|
238
|
+
if (opts.isAdmin) {
|
|
239
|
+
manifestLoaders.push((0, manifest_widgets_1.createWidgetManifestGenerator)({
|
|
240
|
+
baseDirectory: opts.baseDirectory,
|
|
241
|
+
isAdmin: true,
|
|
242
|
+
isDev: isDev,
|
|
243
|
+
isServerless: isServerless,
|
|
244
|
+
watch: isDev,
|
|
245
|
+
onGenerate: (manifest) => {
|
|
246
|
+
writeVirtualModule(ALIAS["@manifest/widgets"], manifest);
|
|
247
|
+
},
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
writeVirtualModule(ALIAS["@manifest/widgets"], `
|
|
252
|
+
export default {}
|
|
253
|
+
`);
|
|
254
|
+
}
|
|
255
|
+
// Block manifest
|
|
256
|
+
ALIAS["@manifest/blocks"] = path_1.default.resolve(opts.baseDirectory, "_blocks_manifest.js");
|
|
257
|
+
manifestLoaders.push((0, manifest_blocks_1.createBlockManifestGenerator)({
|
|
258
|
+
baseDirectory: opts.baseDirectory,
|
|
259
|
+
isAdmin: opts.isAdmin,
|
|
260
|
+
isDev: isDev,
|
|
261
|
+
isServerless: isServerless,
|
|
262
|
+
watch: isDev,
|
|
263
|
+
onGenerate: (manifest) => {
|
|
264
|
+
writeVirtualModule(ALIAS["@manifest/blocks"], manifest);
|
|
265
|
+
},
|
|
266
|
+
}));
|
|
267
|
+
// Wait for all manifests to resolve
|
|
268
|
+
await Promise.all(manifestLoaders);
|
|
269
|
+
// External Gutenberg
|
|
270
|
+
EXTERNALS["@wordpress/components"] = ["window", "wp"];
|
|
271
|
+
EXTERNALS["@wordpress/element"] = ["window", "wp"];
|
|
272
|
+
EXTERNALS["@wordpress/blocks"] = ["window", "wp"];
|
|
273
|
+
EXTERNALS["@wordpress/utils"] = ["window", "wp"];
|
|
274
|
+
EXTERNALS["@wordpress/data"] = ["window", "wp"];
|
|
275
|
+
EXTERNALS["@wordpress/hooks"] = ["window", "wp"];
|
|
276
|
+
EXTERNALS["@wordpress/block-editor"] = ["window", "wp"];
|
|
277
|
+
if (opts.isAdmin) {
|
|
278
|
+
EXTERNALS["@wordpress/components"] = ["wp", "components"];
|
|
279
|
+
EXTERNALS["@wordpress/element"] = ["wp", "element"];
|
|
280
|
+
EXTERNALS["@wordpress/blocks"] = ["wp", "blocks"];
|
|
281
|
+
EXTERNALS["@wordpress/utils"] = ["wp", "utils"];
|
|
282
|
+
EXTERNALS["@wordpress/data"] = ["wp", "data"];
|
|
283
|
+
EXTERNALS["@wordpress/hooks"] = ["wp", "hooks"];
|
|
284
|
+
EXTERNALS["@wordpress/block-editor"] = ["wp", "blockEditor"];
|
|
285
|
+
EXTERNALS["react"] = "React";
|
|
286
|
+
EXTERNALS["react-dom"] = "ReactDOM";
|
|
287
|
+
}
|
|
288
|
+
// Define some values
|
|
289
|
+
DEFINES["process.browser"] = JSON.stringify(isBrowser);
|
|
290
|
+
DEFINES["process.client"] = JSON.stringify(isBrowser);
|
|
291
|
+
DEFINES["process.serverless"] = "false";
|
|
292
|
+
DEFINES["process.ssr"] = JSON.stringify(isServerless && !isBrowser);
|
|
293
|
+
DEFINES["process.LOADABLE_STATS_FILE"] = JSON.stringify(loadableManifestFile);
|
|
294
|
+
DEFINES["process.dev"] = isDev ? "true" : "false";
|
|
295
|
+
DEFINES["process.admin"] = opts.isAdmin ? "true" : "false";
|
|
296
|
+
DEFINES["process.env.themePath"] = JSON.stringify(`/wp-content/themes/${opts.themeName}`);
|
|
297
|
+
DEFINES["process.themePath"] = JSON.stringify(`/wp-content/themes/${opts.themeName}`);
|
|
298
|
+
if (isDev && opts.isAdmin) {
|
|
299
|
+
DEFINES["process.BLOCK_MANIFEST_FILE"] = JSON.stringify(ALIAS["@manifest/blocks"]);
|
|
300
|
+
}
|
|
301
|
+
DEFINES["process.devUI"] = config.devUI === "enabled";
|
|
302
|
+
DEFINES["process.serverlessEndpoint"] = "(window.SERVERLESS_ENDPOINT || '')";
|
|
303
|
+
const rpcExists = (0, fs_1.existsSync)(path_1.default.join(opts.baseDirectory, "apis/_rpc.ts")) ||
|
|
304
|
+
(0, fs_1.existsSync)(path_1.default.join(opts.baseDirectory, "apis/_rpc/index.ts"));
|
|
305
|
+
DEFINES["process.rpcEnabled"] = rpcExists ? "true" : "false";
|
|
306
|
+
if (isBrowser) {
|
|
307
|
+
DEFINES["process.env.themePath"] = `window.THEME_PATH || ${DEFINES["process.env.themePath"]}`;
|
|
308
|
+
}
|
|
309
|
+
const buildID = Date.now();
|
|
310
|
+
return {
|
|
311
|
+
mode: opts.mode,
|
|
312
|
+
context: opts.baseDirectory,
|
|
313
|
+
target: opts.target === "ssr" ? "node" : "web",
|
|
314
|
+
optimization: {
|
|
315
|
+
splitChunks: {
|
|
316
|
+
chunks: "async",
|
|
317
|
+
},
|
|
318
|
+
minimize: opts.mode === "production",
|
|
319
|
+
// chunkIds: "named",
|
|
320
|
+
},
|
|
321
|
+
output: {
|
|
322
|
+
filename: `[name].${opts.isAdmin ? "admin" : "frontend"}.js?v=${buildID}`,
|
|
323
|
+
chunkFilename: `[name].${opts.isAdmin ? "admin" : "frontend"}.js?v=${buildID}`,
|
|
324
|
+
publicPath: `/wp-content/themes/${opts.themeName}/dist/${distSuffix}/`,
|
|
325
|
+
path: outputFolder,
|
|
326
|
+
globalObject: isSSR ? "this" : "self",
|
|
327
|
+
clean: true,
|
|
328
|
+
},
|
|
329
|
+
externals: {
|
|
330
|
+
worker_threads: true,
|
|
331
|
+
...EXTERNALS,
|
|
332
|
+
},
|
|
333
|
+
resolve: {
|
|
334
|
+
alias: ALIAS,
|
|
335
|
+
extensions: [".js", ".jsx", ".ts", ".tsx"],
|
|
336
|
+
},
|
|
337
|
+
entry: ENTRY,
|
|
338
|
+
plugins: [
|
|
339
|
+
...PLUGINS,
|
|
340
|
+
() => {
|
|
341
|
+
compiling = true;
|
|
342
|
+
},
|
|
343
|
+
],
|
|
344
|
+
module: {
|
|
345
|
+
rules: RULES,
|
|
346
|
+
},
|
|
347
|
+
devtool: opts.mode === "development" && opts.target === "client"
|
|
348
|
+
? opts.mode === "development"
|
|
349
|
+
? "cheap-module-source-map"
|
|
350
|
+
: "source-map"
|
|
351
|
+
: false,
|
|
352
|
+
stats: {
|
|
353
|
+
all: true,
|
|
354
|
+
errorDetails: true,
|
|
355
|
+
errors: true,
|
|
356
|
+
colors: true,
|
|
357
|
+
},
|
|
358
|
+
};
|
|
413
359
|
}
|
|
414
360
|
exports.default = getWebpackConfig;
|