@playcraft/devkit 1.0.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/LICENSE +21 -0
- package/cli/bin/playable-scripts.js +2 -0
- package/cli/commands/build.js +1 -0
- package/cli/commands/builds.js +16 -0
- package/cli/commands/dev.js +1 -0
- package/core/batch-build.js +149 -0
- package/core/cos-uploader.js +42 -0
- package/core/index.d.ts +167 -0
- package/core/index.js +1 -0
- package/core/loaders/gltf-loader.js +45 -0
- package/core/options.js +25 -0
- package/core/plugins/AdikteevInjectorPlugin.js +47 -0
- package/core/plugins/BigoAdsInjectorPlugin.js +7 -0
- package/core/plugins/DAPIInjectorPlugin.js +5 -0
- package/core/plugins/DebuggerInjectionPlugin.js +6 -0
- package/core/plugins/ExitAPIInjectorPlugin.js +10 -0
- package/core/plugins/FflateCompressionPlugin.js +225 -0
- package/core/plugins/LiftoffInjectorPlugin.js +14 -0
- package/core/plugins/MRAIDInjectorPlugin.js +4 -0
- package/core/plugins/MintegralInjectorPlugin.js +5 -0
- package/core/plugins/PangleInjectorPlugin.js +4 -0
- package/core/plugins/SnapchatInjectorPlugin.js +20 -0
- package/core/plugins/TikTokInjectorPlugin.js +4 -0
- package/core/plugins/UnityInjectorPlugin.js +20 -0
- package/core/plugins/ZipPlugin.js +19 -0
- package/core/resources/bigoads-config.json +1 -0
- package/core/resources/snapchat-config.json +1 -0
- package/core/resources/tiktok-config.json +1 -0
- package/core/utils/buildDefines.js +3 -0
- package/core/utils/buildTemplateString.js +6 -0
- package/core/utils/date.js +1 -0
- package/core/utils/generateAdikteevHtmlWebpackPluginConfig.js +36 -0
- package/core/utils/generateBigabidHtmlWebpackPluginConfig.js +13 -0
- package/core/utils/generateInMobiHtmlWebpackPluginConfig.js +36 -0
- package/core/utils/injectSDKPlugins.js +19 -0
- package/core/utils/logOptions.js +5 -0
- package/core/utils/mergeOptions.js +6 -0
- package/core/utils/parseArgvOptions.js +7 -0
- package/core/webpack.build.js +60 -0
- package/core/webpack.common.js +10 -0
- package/core/webpack.dev.js +15 -0
- package/defines.d.ts +54 -0
- package/package.json +79 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";const path=require("path");const fs=require("fs");const TsconfigPathsPlugin=require("tsconfig-paths-webpack-plugin");const{VueLoaderPlugin}=require("vue-loader");const{options}=require("./options");const tsConfigPath=path.resolve(options.tsConfig);const jsConfigPath=path.resolve(options.jsConfig);let jsTsConfigPath=null;if(fs.existsSync(tsConfigPath)){jsTsConfigPath=tsConfigPath}else if(fs.existsSync(jsConfigPath)){jsTsConfigPath=jsConfigPath}/** @type {string[]} List of file extensions that webpack will resolve */const allowedExtensions=[".vue",".ts",".tsx",".js",".json",".png",".glb",".fbx",".obj",".jpg",".webp",".mp3",".svg",".xml",".atlas",".fnt",".css",".gif",".mp4",".woff",".woff2",".ttf",".otf"];/** @type {import('webpack').Configuration} Base webpack configuration used by both development and build configs */const webpackConfig={entry:path.resolve("src/index"),resolve:{extensions:allowedExtensions,alias:{assets:path.resolve("assets"),vue:"vue/dist/vue.esm-bundler.js","@":path.resolve("src")},plugins:jsTsConfigPath?[new TsconfigPathsPlugin({configFile:jsTsConfigPath,extensions:allowedExtensions})]:[]},output:{filename:"build.js",path:path.resolve("dist")},module:{rules:[// Vue 单文件组件
|
|
2
|
+
{test:/\.vue$/,loader:"vue-loader"},// {
|
|
3
|
+
// test: /\.tsx?$/,
|
|
4
|
+
// use: 'ts-loader',
|
|
5
|
+
// exclude: /node_modules/,
|
|
6
|
+
// },
|
|
7
|
+
{test:/\.ts?$/,exclude:/node_modules/,use:[{loader:"babel-loader",options:{// presets: ['@babel/preset-env'],
|
|
8
|
+
plugins:options.compilation.allowTemplateLiterals===false?["@babel/plugin-transform-template-literals"]:[]}},{loader:"esbuild-loader",options:{loader:"ts",target:"es2015"}}]},{test:/\.css$/,use:["style-loader","css-loader"]},{test:/\.(js|mjs)$/,// exclude: /node_modules/,
|
|
9
|
+
use:{loader:"babel-loader",options:{// presets: ['@babel/preset-env'],
|
|
10
|
+
plugins:options.compilation.allowTemplateLiterals===false?["@babel/plugin-transform-template-literals"]:[]}}},{test:/\.(gltf)$/,loader:path.join(__dirname,"loaders/gltf-loader.js")},{test:/\.(gif|png|jpe?g|webp|mp3|mp4|m4a|ogg|wav|glb|fbx|obj)$/i,type:"asset/inline"},{test:/\.(svg|xml|json)$/i,type:"asset/source"},{test:/\.atlas$/,type:"asset/inline",generator:{dataUrl:content=>{return`data:text/atlas;base64,${content.toString("base64")}`}}},{test:/\.fnt$/i,type:"asset/inline",generator:{dataUrl:content=>{return`data:text/plain;base64,${content.toString("base64")}`}}},{test:/\.(woff|woff2|eot|ttf|otf)$/i,type:"asset/inline"}]},plugins:[new VueLoaderPlugin]};exports.allowedExtensions=allowedExtensions;exports.webpackCommonConfig=webpackConfig;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";const{merge}=require("webpack-merge");const webpack=require("webpack");const HtmlWebpackPlugin=require("html-webpack-plugin");const WebpackDevServer=require("webpack-dev-server");const{webpackCommonConfig}=require("./webpack.common.js");const path=require("path");const{DebuggerInjectionPlugin}=require("./plugins/DebuggerInjectionPlugin.js");const{options}=require("./options.js");const{mergeOptions}=require("./utils/mergeOptions.js");const{buildDefines}=require("./utils/buildDefines.js");const{logOptions}=require("./utils/logOptions.js");const{injectSDKPlugins}=require("./utils/injectSDKPlugins.js");/**
|
|
2
|
+
* Creates webpack configuration for development
|
|
3
|
+
* @param {Partial<import('./index').CLIOptions>} [customOptions] - Custom options to merge with default options
|
|
4
|
+
* @param {Record<string, any>} [customDefines] - Additional defines for webpack.DefinePlugin
|
|
5
|
+
* @param {import('webpack').Configuration} [webpackCustomConfig] - Custom webpack config to merge
|
|
6
|
+
* @returns {import('webpack').Configuration} Final webpack development configuration
|
|
7
|
+
*/function makeWebpackDevConfig(customOptions,customDefines,webpackCustomConfig){const devOptions=mergeOptions(options,customOptions);logOptions(devOptions);customDefines=customDefines||{};webpackCustomConfig=webpackCustomConfig||{};const webpackConfig=merge(webpackCommonConfig,{mode:"development",devtool:"inline-source-map",devServer:{static:{directory:path.resolve("dist")},hot:true,// compress: true,
|
|
8
|
+
port:devOptions["port"],allowedHosts:"all",open:devOptions["open"]},plugins:[new HtmlWebpackPlugin({template:path.resolve("src/index.html"),inlineSource:".(js|css|png|jpg|webp|svg|xml|atlas|mp3|gif|glb|fbx|obj)$",meta:{viewport:"width=device-width,initial-scale=1.0,viewport-fit=cover,maximum-scale=1.0,user-scalable=no"}}),new webpack.DefinePlugin({...buildDefines(),...devOptions.defines,__DEV__:JSON.stringify(devOptions["dev"]===undefined?true:devOptions["dev"]),...customDefines})]},webpackCustomConfig);if(devOptions["debugger"]){webpackConfig.plugins.push(new DebuggerInjectionPlugin(devOptions["debugger"]))}// 注入渠道 SDK 插件(与 build 保持一致)
|
|
9
|
+
injectSDKPlugins(webpackConfig,{network:devOptions["network"],protocol:devOptions["protocol"],orientation:devOptions["orientation"]});return webpackConfig}/**
|
|
10
|
+
* Starts webpack development server
|
|
11
|
+
* @param {import('webpack').Configuration} [webpackConfig] - Webpack configuration to use, creates default if not provided
|
|
12
|
+
* @param {Partial<import('./index').CLIOptions>} [customOptions] - Custom options to merge with default options
|
|
13
|
+
* @param {Record<string, any>} [customDefines] - Additional defines for webpack.DefinePlugin
|
|
14
|
+
* @param {import('webpack').Configuration} [webpackCustomConfig] - Custom webpack config to merge
|
|
15
|
+
*/function runDev(webpackConfig,customOptions,customDefines,webpackCustomConfig){if(!webpackConfig)webpackConfig=makeWebpackDevConfig(customOptions,customDefines,webpackCustomConfig);const compiler=webpack(webpackConfig);const server=new WebpackDevServer(webpackConfig.devServer,compiler);server.start()}exports.makeWebpackDevConfig=makeWebpackDevConfig;exports.runDev=runDev;
|
package/defines.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
declare module '*.png';
|
|
2
|
+
declare module '*.jpg';
|
|
3
|
+
declare module '*.svg';
|
|
4
|
+
declare module '*.webp';
|
|
5
|
+
declare module '*.xml';
|
|
6
|
+
declare module '*.atlas';
|
|
7
|
+
declare module '*.glb';
|
|
8
|
+
declare module '*.gltf';
|
|
9
|
+
declare module '*.fbx';
|
|
10
|
+
declare module '*.obj';
|
|
11
|
+
declare module '*.mp3';
|
|
12
|
+
declare module '*.mp4';
|
|
13
|
+
declare module '*.otf';
|
|
14
|
+
declare module '*.ttf';
|
|
15
|
+
declare module '*.woff';
|
|
16
|
+
declare module '*.woff2';
|
|
17
|
+
|
|
18
|
+
declare const AD_NETWORK:
|
|
19
|
+
| 'preview'
|
|
20
|
+
| 'applovin'
|
|
21
|
+
| 'unity'
|
|
22
|
+
| 'google'
|
|
23
|
+
| 'ironsource'
|
|
24
|
+
| 'facebook'
|
|
25
|
+
| 'moloco'
|
|
26
|
+
| 'mintegral'
|
|
27
|
+
| 'vungle'
|
|
28
|
+
| 'adcolony'
|
|
29
|
+
| 'tapjoy'
|
|
30
|
+
| 'snapchat'
|
|
31
|
+
| 'tiktok'
|
|
32
|
+
| 'appreciate'
|
|
33
|
+
| 'chartboost'
|
|
34
|
+
| 'pangle'
|
|
35
|
+
| 'mytarget'
|
|
36
|
+
| 'liftoff'
|
|
37
|
+
| 'smadex'
|
|
38
|
+
| 'adikteev'
|
|
39
|
+
| 'bigabid'
|
|
40
|
+
| 'inmobi'
|
|
41
|
+
| 'bigoads';
|
|
42
|
+
|
|
43
|
+
declare const AD_PROTOCOL: 'mraid' | 'dapi' | 'nucleo' | 'none';
|
|
44
|
+
|
|
45
|
+
declare const GOOGLE_PLAY_URL: string;
|
|
46
|
+
declare const APP_STORE_URL: string;
|
|
47
|
+
declare const APP: string;
|
|
48
|
+
declare const NAME: string;
|
|
49
|
+
declare const VERSION: string;
|
|
50
|
+
declare const LANGUAGE: 'auto' | 'en' | 'es' | 'zh' | 'hi' | 'ar' | 'fr' | 'de' | 'ja' | 'pt';
|
|
51
|
+
declare const ORIENTATION: 'both' | 'portrait' | 'landscape' | 'square';
|
|
52
|
+
declare const BUILD_HASH: string;
|
|
53
|
+
|
|
54
|
+
declare const __DEV__: boolean;
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@playcraft/devkit",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "HTML5 Playable Ads 构建工具,支持多广告渠道打包",
|
|
5
|
+
"main": "core/index.js",
|
|
6
|
+
"module": "core/index.js",
|
|
7
|
+
"types": "core/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"playable-scripts": "cli/bin/playable-scripts.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"cli",
|
|
13
|
+
"core",
|
|
14
|
+
"LICENSE",
|
|
15
|
+
"defines.d.ts"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"deploy": "npm publish --registry https://www.npmjs.com/registry"
|
|
19
|
+
},
|
|
20
|
+
"author": "Tencent ADS Team",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@babel/core": "^7.26.0",
|
|
24
|
+
"@babel/preset-env": "^7.26.0",
|
|
25
|
+
"@vue/compiler-sfc": "^3.4.0",
|
|
26
|
+
"babel-loader": "^9.2.1",
|
|
27
|
+
"copy-webpack-plugin": "^13.0.0",
|
|
28
|
+
"cos-nodejs-sdk-v5": "^2.14.4",
|
|
29
|
+
"cross-spawn": "^7.0.3",
|
|
30
|
+
"css-loader": "^7.1.2",
|
|
31
|
+
"esbuild-loader": "^4.2.2",
|
|
32
|
+
"fflate": "^0.8.2",
|
|
33
|
+
"html-inline-script-webpack-plugin": "^3.2.1",
|
|
34
|
+
"html-webpack-plugin": "^5.6.0",
|
|
35
|
+
"mini-css-extract-plugin": "^2.7.6",
|
|
36
|
+
"prettyjson": "^1.2.5",
|
|
37
|
+
"style-loader": "^4.0.0",
|
|
38
|
+
"tencentcloud-sdk-nodejs-cdn": "^4.1.161",
|
|
39
|
+
"terser-webpack-plugin": "^5.3.10",
|
|
40
|
+
"tsconfig-paths-webpack-plugin": "^4.2.0",
|
|
41
|
+
"vue": "^3.4.0",
|
|
42
|
+
"vue-loader": "^17.4.2",
|
|
43
|
+
"webpack": "^5.91.0",
|
|
44
|
+
"webpack-dev-server": "^5.1.0",
|
|
45
|
+
"webpack-merge": "^5.10.0",
|
|
46
|
+
"webpack-obfuscator": "^3.6.0",
|
|
47
|
+
"yazl": "^2.5.1"
|
|
48
|
+
},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=14.0.0"
|
|
51
|
+
},
|
|
52
|
+
"keywords": [
|
|
53
|
+
"playable",
|
|
54
|
+
"scripts",
|
|
55
|
+
"builder",
|
|
56
|
+
"playable-ads",
|
|
57
|
+
"html5-ads",
|
|
58
|
+
"ad-network",
|
|
59
|
+
"ad-builder",
|
|
60
|
+
"compression",
|
|
61
|
+
"fflate",
|
|
62
|
+
"optimization",
|
|
63
|
+
"tencent",
|
|
64
|
+
"bigoads",
|
|
65
|
+
"mraid",
|
|
66
|
+
"vungle",
|
|
67
|
+
"applovin",
|
|
68
|
+
"google-ads",
|
|
69
|
+
"meta-ads",
|
|
70
|
+
"unity-ads",
|
|
71
|
+
"ironsource",
|
|
72
|
+
"webpack",
|
|
73
|
+
"cli-tool",
|
|
74
|
+
"build-tool"
|
|
75
|
+
],
|
|
76
|
+
"publishConfig": {
|
|
77
|
+
"registry": "https://www.npmjs.com/registry"
|
|
78
|
+
}
|
|
79
|
+
}
|