@playcraft/devkit 1.0.16 → 1.0.18
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 +259 -0
- package/cli/bin/playable-scripts.js +44 -1
- package/cli/commands/build.js +130 -17
- package/cli/commands/builds.js +13 -2
- package/cli/commands/dev.js +7 -1
- package/cli/commands/pack.js +308 -39
- package/cli/commands/vite-dev.js +7 -1
- package/core/batch-build.js +1091 -124
- package/core/cos-uploader.js +264 -20
- package/core/index.js +71 -4
- package/core/loaders/gltf-loader.js +74 -28
- package/core/options.js +310 -15
- package/core/plugins/AdikteevInjectorPlugin.js +26 -4
- package/core/plugins/BigoAdsInjectorPlugin.js +21 -4
- package/core/plugins/DAPIInjectorPlugin.js +25 -2
- package/core/plugins/DebuggerInjectionPlugin.js +31 -3
- package/core/plugins/ExitAPIInjectorPlugin.js +57 -3
- package/core/plugins/FflateCompressionPlugin.js +225 -37
- package/core/plugins/FontInjectionWebpackPlugin.js +59 -0
- package/core/plugins/LiftoffInjectorPlugin.js +26 -4
- package/core/plugins/MRAIDInjectorPlugin.js +24 -2
- package/core/plugins/MintegralInjectorPlugin.js +25 -2
- package/core/plugins/PangleInjectorPlugin.js +24 -2
- package/core/plugins/SnapchatInjectorPlugin.js +26 -4
- package/core/plugins/TikTokInjectorPlugin.js +24 -2
- package/core/plugins/UnityInjectorPlugin.js +37 -8
- package/core/plugins/ZipPlugin.js +138 -19
- package/core/resources/fonts/README.md +31 -0
- package/core/resources/fonts/maoken-regular.woff2 +0 -0
- package/core/resources/fonts/maoken-regular.woff2.chars +1 -0
- package/core/resources/fonts/maoken-zhuyuan.ttf +0 -0
- package/core/resources/fonts/noto-sans-sc-regular.woff2 +0 -0
- package/core/resources/fonts/pangmen-biaoti.ttf +0 -0
- package/core/resources/fonts/pangmen-regular.woff2 +0 -0
- package/core/resources/fonts/pangmen-regular.woff2.chars +1 -0
- package/core/resources/fonts/poppins-regular.woff2 +0 -0
- package/core/utils/buildDefines.js +29 -2
- package/core/utils/buildTemplateString.js +40 -5
- package/core/utils/date.js +16 -1
- package/core/utils/fontRegistry.js +97 -0
- package/core/utils/fontResolver.js +398 -0
- package/core/utils/generateAdikteevHtmlWebpackPluginConfig.js +42 -7
- package/core/utils/generateBigabidHtmlWebpackPluginConfig.js +30 -3
- package/core/utils/generateInMobiHtmlWebpackPluginConfig.js +43 -7
- package/core/utils/injectSDKPlugins.js +58 -11
- package/core/utils/logOptions.js +37 -4
- package/core/utils/mergeOptions.js +19 -2
- package/core/utils/parseArgvOptions.js +110 -5
- package/core/utils/resolveChannelFold2Zip.js +15 -3
- package/core/utils/validateThemeData.js +220 -25
- package/core/validators/pre-build-checker.js +201 -21
- package/core/validators/tracking-validator.js +358 -40
- package/core/vite.dev.js +332 -16
- package/core/webpack.build.js +494 -52
- package/core/webpack.common.js +177 -11
- package/core/webpack.dev.js +82 -5
- package/package.json +3 -2
package/core/webpack.common.js
CHANGED
|
@@ -1,11 +1,177 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
|
4
|
+
const { VueLoaderPlugin } = require('vue-loader');
|
|
5
|
+
const { options } = require('./options');
|
|
6
|
+
|
|
7
|
+
const tsConfigPath = path.resolve(options.tsConfig);
|
|
8
|
+
const jsConfigPath = path.resolve(options.jsConfig);
|
|
9
|
+
let jsTsConfigPath = null;
|
|
10
|
+
if (fs.existsSync(tsConfigPath)) {
|
|
11
|
+
jsTsConfigPath = tsConfigPath;
|
|
12
|
+
} else if (fs.existsSync(jsConfigPath)) {
|
|
13
|
+
jsTsConfigPath = jsConfigPath;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** @type {string[]} List of file extensions that webpack will resolve */
|
|
17
|
+
const allowedExtensions = [
|
|
18
|
+
'.vue',
|
|
19
|
+
'.ts',
|
|
20
|
+
'.tsx',
|
|
21
|
+
'.js',
|
|
22
|
+
'.json',
|
|
23
|
+
'.json5',
|
|
24
|
+
'.png',
|
|
25
|
+
'.glb',
|
|
26
|
+
'.fbx',
|
|
27
|
+
'.obj',
|
|
28
|
+
'.jpg',
|
|
29
|
+
'.webp',
|
|
30
|
+
'.mp3',
|
|
31
|
+
'.svg',
|
|
32
|
+
'.xml',
|
|
33
|
+
'.atlas',
|
|
34
|
+
'.fnt',
|
|
35
|
+
'.css',
|
|
36
|
+
'.gif',
|
|
37
|
+
'.mp4',
|
|
38
|
+
'.woff',
|
|
39
|
+
'.woff2',
|
|
40
|
+
'.ttf',
|
|
41
|
+
'.otf'
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
/** @type {import('webpack').Configuration} Base webpack configuration used by both development and build configs */
|
|
45
|
+
const webpackConfig = {
|
|
46
|
+
entry: path.resolve('src/index'),
|
|
47
|
+
resolve: {
|
|
48
|
+
extensions: allowedExtensions,
|
|
49
|
+
alias: {
|
|
50
|
+
assets: path.resolve('assets'),
|
|
51
|
+
vue: 'vue/dist/vue.esm-bundler.js',
|
|
52
|
+
'@': path.resolve('src'),
|
|
53
|
+
},
|
|
54
|
+
plugins: jsTsConfigPath
|
|
55
|
+
? [
|
|
56
|
+
new TsconfigPathsPlugin({
|
|
57
|
+
configFile: jsTsConfigPath,
|
|
58
|
+
extensions: allowedExtensions
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
: []
|
|
62
|
+
},
|
|
63
|
+
output: {
|
|
64
|
+
filename: 'build.js',
|
|
65
|
+
path: path.resolve('dist')
|
|
66
|
+
},
|
|
67
|
+
module: {
|
|
68
|
+
rules: [
|
|
69
|
+
// Vue 单文件组件
|
|
70
|
+
{
|
|
71
|
+
test: /\.vue$/,
|
|
72
|
+
loader: 'vue-loader'
|
|
73
|
+
},
|
|
74
|
+
// {
|
|
75
|
+
// test: /\.tsx?$/,
|
|
76
|
+
// use: 'ts-loader',
|
|
77
|
+
// exclude: /node_modules/,
|
|
78
|
+
// },
|
|
79
|
+
{
|
|
80
|
+
test: /\.ts?$/,
|
|
81
|
+
exclude: /node_modules/,
|
|
82
|
+
use: [
|
|
83
|
+
{
|
|
84
|
+
loader: 'babel-loader',
|
|
85
|
+
options: {
|
|
86
|
+
// presets: ['@babel/preset-env'],
|
|
87
|
+
plugins:
|
|
88
|
+
options.compilation.allowTemplateLiterals === false ? ['@babel/plugin-transform-template-literals'] : []
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
{
|
|
93
|
+
loader: 'esbuild-loader',
|
|
94
|
+
options: {
|
|
95
|
+
loader: 'ts',
|
|
96
|
+
target: 'es2015'
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
test: /\.css$/,
|
|
103
|
+
use: ['style-loader', 'css-loader']
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
test: /\.(js|mjs)$/,
|
|
107
|
+
// exclude: /node_modules/,
|
|
108
|
+
use: {
|
|
109
|
+
loader: 'babel-loader',
|
|
110
|
+
options: {
|
|
111
|
+
// presets: ['@babel/preset-env'],
|
|
112
|
+
plugins: options.compilation.allowTemplateLiterals === false ? ['@babel/plugin-transform-template-literals'] : []
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
test: /\.(gltf)$/,
|
|
118
|
+
loader: path.join(__dirname, 'loaders/gltf-loader.js')
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
test: /\.(gif|png|jpe?g|webp|mp3|mp4|m4a|ogg|wav|glb|fbx|obj)$/i,
|
|
122
|
+
type: 'asset/inline'
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
test: /\.json5$/i,
|
|
126
|
+
type: 'javascript/auto',
|
|
127
|
+
use: {
|
|
128
|
+
loader: 'json5-loader',
|
|
129
|
+
options: {
|
|
130
|
+
esModule: false
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
// 处理 json?url → base64
|
|
135
|
+
{
|
|
136
|
+
test: /\.json$/i,
|
|
137
|
+
resourceQuery: /url/,
|
|
138
|
+
type: 'asset/inline',
|
|
139
|
+
generator: {
|
|
140
|
+
dataUrl: (content) => `data:application/json;base64,${content.toString('base64')}`
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
test: /\.(svg|xml)$/i,
|
|
145
|
+
type: 'asset/source'
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
test: /\.atlas$/,
|
|
149
|
+
type: 'asset/inline',
|
|
150
|
+
generator: {
|
|
151
|
+
dataUrl: (content) => {
|
|
152
|
+
return `data:text/atlas;base64,${content.toString('base64')}`;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
test: /\.fnt$/i,
|
|
158
|
+
type: 'asset/inline',
|
|
159
|
+
generator: {
|
|
160
|
+
dataUrl: (content) => {
|
|
161
|
+
return `data:text/plain;base64,${content.toString('base64')}`;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
167
|
+
type: 'asset/inline'
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
},
|
|
171
|
+
plugins: [
|
|
172
|
+
new VueLoaderPlugin()
|
|
173
|
+
]
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
exports.allowedExtensions = allowedExtensions;
|
|
177
|
+
exports.webpackCommonConfig = webpackConfig;
|
package/core/webpack.dev.js
CHANGED
|
@@ -1,15 +1,92 @@
|
|
|
1
|
-
|
|
1
|
+
const { merge } = require('webpack-merge');
|
|
2
|
+
const webpack = require('webpack');
|
|
3
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
4
|
+
const WebpackDevServer = require('webpack-dev-server');
|
|
5
|
+
const { webpackCommonConfig } = require('./webpack.common.js');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { DebuggerInjectionPlugin } = require('./plugins/DebuggerInjectionPlugin.js');
|
|
8
|
+
const { options } = require('./options.js');
|
|
9
|
+
const { mergeOptions } = require('./utils/mergeOptions.js');
|
|
10
|
+
const { buildDefines } = require('./utils/buildDefines.js');
|
|
11
|
+
const { logOptions } = require('./utils/logOptions.js');
|
|
12
|
+
const { injectSDKPlugins } = require('./utils/injectSDKPlugins.js');
|
|
13
|
+
|
|
14
|
+
/**
|
|
2
15
|
* Creates webpack configuration for development
|
|
3
16
|
* @param {Partial<import('./index').CLIOptions>} [customOptions] - Custom options to merge with default options
|
|
4
17
|
* @param {Record<string, any>} [customDefines] - Additional defines for webpack.DefinePlugin
|
|
5
18
|
* @param {import('webpack').Configuration} [webpackCustomConfig] - Custom webpack config to merge
|
|
6
19
|
* @returns {import('webpack').Configuration} Final webpack development configuration
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
20
|
+
*/
|
|
21
|
+
function makeWebpackDevConfig(customOptions, customDefines, webpackCustomConfig) {
|
|
22
|
+
const devOptions = mergeOptions(options, customOptions);
|
|
23
|
+
logOptions(devOptions)
|
|
24
|
+
customDefines = customDefines || {};
|
|
25
|
+
webpackCustomConfig = webpackCustomConfig || {};
|
|
26
|
+
|
|
27
|
+
const webpackConfig = merge(
|
|
28
|
+
webpackCommonConfig,
|
|
29
|
+
{
|
|
30
|
+
mode: 'development',
|
|
31
|
+
devtool: 'inline-source-map',
|
|
32
|
+
devServer: {
|
|
33
|
+
static: {
|
|
34
|
+
directory: path.resolve('dist')
|
|
35
|
+
},
|
|
36
|
+
hot: true,
|
|
37
|
+
// compress: true,
|
|
38
|
+
port: devOptions['port'],
|
|
39
|
+
allowedHosts: 'all',
|
|
40
|
+
open: devOptions['open']
|
|
41
|
+
},
|
|
42
|
+
plugins: [
|
|
43
|
+
new HtmlWebpackPlugin({
|
|
44
|
+
template: path.resolve('src/index.html'),
|
|
45
|
+
inlineSource: '.(js|css|png|jpg|webp|svg|xml|atlas|mp3|gif|glb|fbx|obj)$',
|
|
46
|
+
meta: {
|
|
47
|
+
viewport: 'width=device-width,initial-scale=1.0,viewport-fit=cover,maximum-scale=1.0,user-scalable=no'
|
|
48
|
+
}
|
|
49
|
+
}),
|
|
50
|
+
|
|
51
|
+
new webpack.DefinePlugin({
|
|
52
|
+
...buildDefines(),
|
|
53
|
+
...devOptions.defines,
|
|
54
|
+
__DEV__: JSON.stringify(devOptions['dev'] === undefined ? true : devOptions['dev']),
|
|
55
|
+
...customDefines
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
webpackCustomConfig
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
if (devOptions['debugger']) {
|
|
63
|
+
webpackConfig.plugins.push(new DebuggerInjectionPlugin(devOptions['debugger']));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 注入渠道 SDK 插件(与 build 保持一致)
|
|
67
|
+
injectSDKPlugins(webpackConfig, {
|
|
68
|
+
network: devOptions['network'],
|
|
69
|
+
protocol: devOptions['protocol'],
|
|
70
|
+
orientation: devOptions['orientation']
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return webpackConfig;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
10
77
|
* Starts webpack development server
|
|
11
78
|
* @param {import('webpack').Configuration} [webpackConfig] - Webpack configuration to use, creates default if not provided
|
|
12
79
|
* @param {Partial<import('./index').CLIOptions>} [customOptions] - Custom options to merge with default options
|
|
13
80
|
* @param {Record<string, any>} [customDefines] - Additional defines for webpack.DefinePlugin
|
|
14
81
|
* @param {import('webpack').Configuration} [webpackCustomConfig] - Custom webpack config to merge
|
|
15
|
-
*/
|
|
82
|
+
*/
|
|
83
|
+
function runDev(webpackConfig, customOptions, customDefines, webpackCustomConfig) {
|
|
84
|
+
if (!webpackConfig) webpackConfig = makeWebpackDevConfig(customOptions, customDefines, webpackCustomConfig);
|
|
85
|
+
|
|
86
|
+
const compiler = webpack(webpackConfig);
|
|
87
|
+
const server = new WebpackDevServer(webpackConfig.devServer, compiler);
|
|
88
|
+
server.start();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
exports.makeWebpackDevConfig = makeWebpackDevConfig;
|
|
92
|
+
exports.runDev = runDev;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcraft/devkit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "HTML5 Playable Ads 构建工具,支持多广告渠道打包",
|
|
5
5
|
"main": "core/index.js",
|
|
6
6
|
"module": "core/index.js",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"defines.d.ts"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
+
"build": "node scripts/build.js",
|
|
18
19
|
"deploy": "npm run build && cd dist && npm publish --registry https://registry.npmjs.org/ --access public",
|
|
19
20
|
"deploy:beta": "npm run build && cd dist && npm publish --registry https://registry.npmjs.org/ --access public --tag beta"
|
|
20
21
|
},
|
|
@@ -82,4 +83,4 @@
|
|
|
82
83
|
"publishConfig": {
|
|
83
84
|
"registry": "https://www.npmjs.com/registry"
|
|
84
85
|
}
|
|
85
|
-
}
|
|
86
|
+
}
|