-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
2,438 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
/dist | ||
/tmp | ||
/out-tsc | ||
/bundles | ||
|
||
# dependencies | ||
node_modules | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const archiver = require("archiver"); | ||
const package = require("../package.json"); | ||
|
||
const bundleName = `ysdk-cc-${package.version}.zip`; | ||
const bundlePath = path.resolve(__dirname, `../bundles/${bundleName}`); | ||
const output = fs.createWriteStream(bundlePath); | ||
|
||
// create directory ../bundles if not exists | ||
if (!fs.existsSync(path.resolve(__dirname, "../bundles"))) { | ||
fs.mkdirSync(path.resolve(__dirname, "../bundles")); | ||
} | ||
|
||
const archive = archiver("zip", { | ||
zlib: { level: 9 }, | ||
}); | ||
|
||
output.on("close", function () { | ||
const kib = (archive.pointer() / 1048576).toPrecision(3); | ||
console.log(`[${bundleName}] Bundle: Success (${kib} MiB)`); | ||
}); | ||
|
||
archive.on("warning", console.warn); | ||
archive.on("error", console.error); | ||
|
||
archive.pipe(output); | ||
|
||
const folders = ["@cc", "@types", "dist", "docs", "i18n", "static"]; | ||
|
||
folders.forEach((folder) => { | ||
archive.directory("./" + folder, folder); | ||
}); | ||
|
||
const modules = ["i18next"]; | ||
|
||
for (const module of modules) { | ||
archive.directory(`./node_modules/${module}`, `node_modules/${module}`); | ||
} | ||
|
||
const files = [ | ||
"AUTHORS", | ||
"CHANGELOG.md", | ||
"CONTRIBUTING.md", | ||
"LICENSE", | ||
"package.json", | ||
"README_ZH.md", | ||
"README.md", | ||
]; | ||
|
||
files.forEach((file) => { | ||
archive.file("./" + file, { name: file }); | ||
}); | ||
|
||
archive.finalize(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
const { merge } = require("webpack-merge"); | ||
const base = require("./webpack.base.js"); | ||
|
||
/** @type {import('webpack').Configuration} */ | ||
module.exports = merge(base, { | ||
mode: "development", | ||
watch: true, | ||
}); | ||
const { merge } = require("webpack-merge"); | ||
const base = require("./webpack.electron-main.js"); | ||
|
||
/** @type {import('webpack').Configuration} */ | ||
module.exports = merge(base, { | ||
mode: "development", | ||
watch: true, | ||
}); |
220 changes: 116 additions & 104 deletions
220
electron-main/webpack.base.js → scripts/webpack.electron-main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,116 @@ | ||
const { LicenseFilePlugin } = require("generate-license-file-webpack-plugin"); | ||
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin"); | ||
const path = require("path"); | ||
const webpack = require("webpack"); | ||
|
||
const entryFiles = [ | ||
"./src/main.ts", | ||
"./src/scene/index.ts", | ||
"./src/server.ts", | ||
"./src/panels/localization-editor/index.ts", | ||
"./src/builder/index.ts", | ||
"./src/builder/asset-handlers.ts", | ||
"./src/builder/web-hooks.ts", | ||
].reduce((obj, el) => { | ||
el = el.replaceAll("\\", "/"); | ||
obj[el.replace(".ts", "")] = "./" + el; | ||
return obj; | ||
}, {}); | ||
|
||
const optionalPlugins = []; | ||
if (process.platform !== "darwin") { | ||
optionalPlugins.push( | ||
new webpack.IgnorePlugin({ resourceRegExp: /^fsevents$/ }) | ||
); | ||
} | ||
/** @type {import('webpack').Configuration} */ | ||
module.exports = { | ||
target: "electron-main", | ||
devtool: "source-map", | ||
entry: { | ||
...entryFiles, | ||
}, | ||
resolve: { | ||
alias: { | ||
"@common": path.join(__dirname, "../static/assets/common"), | ||
}, | ||
extensions: [".ts", ".tsx", ".js", ".html", ".css", ".sass", ".scss"], | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, // .ts, .tsx | ||
loader: "babel-loader", | ||
exclude: /node_modules/, | ||
}, | ||
{ | ||
test: /\.(s[ac]|c)ss$/, // .css, .sass, .scss | ||
use: ["raw-loader", "sass-loader"], | ||
exclude: /node_modules/, | ||
}, | ||
{ | ||
test: /\.css$/, | ||
use: ["style-loader", "css-loader"], | ||
include: /node_modules/, | ||
}, | ||
{ | ||
test: /\.html$/, | ||
loader: "raw-loader", | ||
}, | ||
{ | ||
test: /.node$/, | ||
loader: "node-loader", | ||
}, | ||
], | ||
}, | ||
optimization: { | ||
minimize: false, | ||
splitChunks: { | ||
cacheGroups: { | ||
defaultVendors: { | ||
test: /[\\/]node_modules[\\/]/, | ||
enforce: true, | ||
reuseExistingChunk: true, | ||
name(module) { | ||
const name = module.resourceResolveData.descriptionFileData?.name; | ||
if (name) return "modules/" + name + "/" + module.buildInfo.hash; | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, "../dist/electron-main"), | ||
libraryTarget: "umd", | ||
}, | ||
externalsPresets: { | ||
node: true, | ||
}, | ||
plugins: [ | ||
...optionalPlugins, | ||
new ForkTsCheckerWebpackPlugin(), | ||
new webpack.DefinePlugin({ | ||
__VUE_OPTIONS_API__: false, | ||
__VUE_PROD_DEVTOOLS__: false, | ||
}), | ||
new LicenseFilePlugin({ | ||
outputFileName: "LICENSE", | ||
outputFolder: "./", // Relative to your build output directory. | ||
pathToPackageJson: "../package.json", | ||
isDev: false, // When true, uses placeholder content to reduce compilation time. | ||
lineEnding: undefined, // Can be 'crlf' or 'lf'. If omitted, the system default will be used. | ||
}), | ||
], | ||
}; | ||
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin"); | ||
const path = require("path"); | ||
const webpack = require("webpack"); | ||
|
||
const entryFiles = [ | ||
"./src/main.ts", | ||
"./src/scene/index.ts", | ||
"./src/server.ts", | ||
"./src/panels/localization-editor/index.ts", | ||
"./src/builder/index.ts", | ||
"./src/builder/asset-handlers.ts", | ||
"./src/builder/web-hooks.ts", | ||
].reduce((obj, el) => { | ||
el = el.replaceAll("\\", "/"); | ||
obj[el.replace(".ts", "")] = "./" + el; | ||
return obj; | ||
}, {}); | ||
|
||
const optionalPlugins = []; | ||
if (process.platform !== "darwin") { | ||
optionalPlugins.push( | ||
new webpack.IgnorePlugin({ resourceRegExp: /^fsevents$/ }) | ||
); | ||
} | ||
|
||
/** @type {import('webpack').Configuration} */ | ||
module.exports = { | ||
target: "electron-main", | ||
devtool: "source-map", | ||
entry: { | ||
...entryFiles, | ||
}, | ||
context: path.resolve(__dirname, "../electron-main/"), | ||
resolve: { | ||
alias: { | ||
"@common": path.join(__dirname, "../static/assets/common"), | ||
}, | ||
extensions: [".ts", ".tsx", ".js", ".html", ".css", ".sass", ".scss"], | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, // .ts, .tsx | ||
use: { | ||
loader: "babel-loader", | ||
options: { | ||
presets: ["@babel/preset-typescript"], | ||
plugins: [ | ||
[ | ||
"@vue/babel-plugin-jsx", | ||
{ | ||
isCustomElement: (tag) => tag.includes("ui-"), | ||
}, | ||
], | ||
"@babel/plugin-transform-modules-commonjs", | ||
], | ||
}, | ||
}, | ||
exclude: /node_modules/, | ||
}, | ||
{ | ||
test: /\.(s[ac]|c)ss$/, // .css, .sass, .scss | ||
use: ["raw-loader", "sass-loader"], | ||
exclude: /node_modules/, | ||
}, | ||
{ | ||
test: /\.css$/, | ||
use: ["style-loader", "css-loader"], | ||
include: /node_modules/, | ||
}, | ||
{ | ||
test: /\.html$/, | ||
loader: "raw-loader", | ||
}, | ||
{ | ||
test: /.node$/, | ||
loader: "node-loader", | ||
}, | ||
], | ||
}, | ||
optimization: { | ||
minimize: false, | ||
splitChunks: { | ||
cacheGroups: { | ||
defaultVendors: { | ||
test: /[\\/]node_modules[\\/]/, | ||
enforce: true, | ||
reuseExistingChunk: true, | ||
name(module) { | ||
const name = module.resourceResolveData.descriptionFileData?.name; | ||
if (name) return "modules/" + name + "/" + module.buildInfo.hash; | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, "../dist/electron-main"), | ||
libraryTarget: "umd", | ||
}, | ||
externalsPresets: { | ||
node: true, | ||
}, | ||
plugins: [ | ||
...optionalPlugins, | ||
new ForkTsCheckerWebpackPlugin({ | ||
typescript: { | ||
configFile: path.resolve(__dirname, "../electron-main/tsconfig.json"), | ||
}, | ||
}), | ||
new webpack.DefinePlugin({ | ||
__VUE_OPTIONS_API__: false, | ||
__VUE_PROD_DEVTOOLS__: false, | ||
}), | ||
], | ||
}; |
Oops, something went wrong.