-
Notifications
You must be signed in to change notification settings - Fork 0
/
globals.js
110 lines (103 loc) · 2.45 KB
/
globals.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
export const imports = `
const { registerBlockType } = wp.blocks;
const { RichText, MediaUpload, InspectorControls } = wp.blockEditor;
const { Panel, PanelBody, PanelRow, TextareaControl, ToggleControl } = wp.components;
`;
export const panels = [];
export const images = [];
export const browserOptions = [
'--remote-debugging-port=9222',
'--no-first-run',
'--no-default-browser-check',
'--disable-background-timer-throttling',
'--disable-backgrounding-occluded-windows',
'--disable-renderer-backgrounding',
];
export const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36';
export const pageOptions = {
waitUntil: 'networkidle2',
};
export const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
export const webpackConfig = `
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import TerserPlugin from 'terser-webpack-plugin';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
export default {
entry: './block.js',
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
keep_fnames: true,
ecma: 6,
},
}),
],
},
output: {
path: __dirname,
filename: 'block.build.js',
},
module: {
rules: [
{
test: /.(js|jsx)$/,
use: ['babel-loader'],
exclude: /node_modules/,
}
]
}
};
`;
export const packageJson = `
{
"name": "wp-block",
"version": "1.0.0",
"main": "block.js",
"type": "module",
"dependencies": {
"@babel/core": "^7.25.2",
"@babel/plugin-transform-react-jsx": "^7.25.2",
"@babel/preset-env": "^7.25.4",
"@babel/preset-react": "^7.24.7",
"babel-loader": "^9.1.3",
"cross-env": "^7.0.3",
"terser-webpack-plugin": "^5.3.10",
"webpack": "^5.94.0",
"webpack-cli": "^5.1.4"
},
"scripts": {
"build": "cross-env BABEL_ENV=default NODE_ENV=production webpack && rm -r node_modules",
"dev": "cross-env BABEL_ENV=default webpack --watch"
}
}
`;
export const babelrc = `
{
"presets": [
[
"@babel/preset-react",
{
"pragma": "wp.element.createElement"
}
]
],
"plugins": [
[
"@babel/plugin-transform-react-jsx",
{
"pragma": "wp.element.createElement"
}
]
]
}
`;
export const editorStyles = `
.editor-styles-wrapper .wp-block {
all: inherit;
}
`;