1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Remove more unused dependencies (#527)

* Remove more unused dependencies

* Remove gulp-jsbeautifier
This commit is contained in:
Bjorn Stromberg
2020-08-07 16:16:23 +09:00
committed by GitHub
parent a44ec7182a
commit 997fabd52c
13 changed files with 90 additions and 1435 deletions

View File

@@ -11,6 +11,7 @@ module.exports = {
);
return commitHash.replace(/^\s+|\s+$/g, "");
},
getAllResourceImages() {
return glob
.sync("res/**/*.@(png|svg|jpg)", { cwd: ".." })
@@ -24,18 +25,6 @@ module.exports = {
});
},
getAllAtlasImages() {
return glob
.sync("res_built/atlas/*.png", { cwd: ".." })
.map(s => s.replace("res_built/atlas/", "res/"));
},
getAllSounds() {
return glob
.sync("res_built/sounds/**/*.mp3", { cwd: ".." })
.map(s => s.replace("res_built/sounds/", "res/sounds/"));
},
getVersion() {
return trim(fs.readFileSync(path.join(__dirname, "..", "version")).toString());
},

19
gulp/cordova.js vendored
View File

@@ -132,25 +132,6 @@ function gulptasksCordova($, gulp, buildFolder) {
})
);
});
// gulp.task("pushToStagingRepo", (cb) => {
// var cmd = spawn('../push-pgb.sh', ['https://TOKEN@github.com/tobspr/shapezapp-cordova-buildslave.git'],
// { stdio: 'inherit', stdout: 'inherit', stderr: 'inherit', shell: true });
// cmd.on('close', function (code) {
// console.log('push staging exited with code ' + code + " / " + cmd.stdout + " / " + cmd.stderr);
// cb(code);
// });
// });
// gulp.task("pushToProdRepo", (cb) => {
// var cmd = spawn('../push-pgb.sh', ['https://TOKEN@github.com/tobspr/shapezapp-cordova-buildslave-release.git'],
// { stdio: 'inherit', stdout: 'inherit', stderr: 'inherit', shell: true });
// cmd.on('close', function (code) {
// console.log('push prod exited with code ' + code + " / " + cmd.stdout + " / " + cmd.stderr);
// cb(code);
// });
// });
}
module.exports = {

View File

@@ -77,7 +77,6 @@ function gulptasksCSS($, gulp, buildFolder, browserSync) {
.pipe($.plumber())
.pipe($.sass.sync({ outputStyle: "compressed" }).on("error", $.sass.logError))
.pipe($.postcss(postcssPlugins(true, { cachebust: true })))
// .pipe($.cssbeautify())
.pipe(gulp.dest(buildFolder))
);
});
@@ -90,7 +89,6 @@ function gulptasksCSS($, gulp, buildFolder, browserSync) {
.pipe($.plumber())
.pipe($.sass.sync({ outputStyle: "compressed" }).on("error", $.sass.logError))
.pipe($.postcss(postcssPlugins(true, { cachebust: false })))
// .pipe($.cssbeautify())
.pipe(gulp.dest(buildFolder))
);
});

View File

@@ -9,7 +9,7 @@ function computeIntegrityHash(fullPath, algorithm = "sha256") {
return algorithm + "-" + hash;
}
function gulptasksHTML($, gulp, buildFolder, browserSync) {
function gulptasksHTML($, gulp, buildFolder) {
const commitHash = buildUtils.getRevision();
async function buildHtml(
apiUrl,
@@ -27,9 +27,8 @@ function gulptasksHTML($, gulp, buildFolder, browserSync) {
return gulp
.src("../src/html/" + (standalone ? "index.standalone.html" : "index.html"))
.pipe(
$.dom(function () {
// @ts-ignore
const document = /** @type {Document} */ (this);
$.dom(/** @this {Document} **/ function () {
const document = this;
// Preconnect to api
const prefetchLink = document.createElement("link");
@@ -38,21 +37,6 @@ function gulptasksHTML($, gulp, buildFolder, browserSync) {
prefetchLink.setAttribute("crossorigin", "anonymous");
document.head.appendChild(prefetchLink);
// // Append css preload
// const cssPreload = document.createElement("link");
// cssPreload.rel = "preload";
// cssPreload.href = cachebust("main.css");
// cssPreload.setAttribute("as", "style");
// document.head.appendChild(cssPreload);
// document.head.appendChild(prefetchLink);
// // Append js preload
// const jsPreload = document.createElement("link");
// jsPreload.rel = "preload";
// jsPreload.href = cachebust("bundle.js");
// jsPreload.setAttribute("as", "script");
// document.head.appendChild(jsPreload);
// Append css
const css = document.createElement("link");
css.rel = "stylesheet";
@@ -68,17 +52,6 @@ function gulptasksHTML($, gulp, buildFolder, browserSync) {
}
document.head.appendChild(css);
if (analytics) {
// Logrocket
// const logrocketScript = document.createElement("script");
// logrocketScript.src = "https://cdn.lr-ingest.io/LogRocket.min.js";
// logrocketScript.setAttribute("crossorigin", "anonymous");
// document.head.appendChild(logrocketScript);
// const logrocketInit = document.createElement("script");
// logrocketInit.textContent = "window.LogRocket && window.LogRocket.init('TODO: GET LOGROCKET ID');";
// document.head.appendChild(logrocketInit);
}
if (app) {
// Append cordova link
const cdv = document.createElement("script");
@@ -114,18 +87,9 @@ function gulptasksHTML($, gulp, buildFolder, browserSync) {
// Do not need to preload in app or standalone
if (!hasLocalFiles) {
// Preload images
const images = buildUtils.getAllResourceImages();
// Preload essentials
const preloads = ["fonts/GameFont.woff2"];
// for (let i = 0; i < images.length; ++i) {
// if (preloads.indexOf(images[i]) < 0) {
// preloads.push(images[i]);
// }
// }
preloads.forEach(src => {
const preloadLink = document.createElement("link");
preloadLink.rel = "preload";
@@ -138,23 +102,6 @@ function gulptasksHTML($, gulp, buildFolder, browserSync) {
}
document.head.appendChild(preloadLink);
});
// Sound preloads
// const sounds = buildUtils.getAllSounds();
// sounds.forEach((src) => {
// if (src.indexOf("sounds/music/") >= 0) {
// // skip music
// return;
// }
// const preloadLink = document.createElement("link");
// preloadLink.rel = "preload";
// preloadLink.href = cachebust(src);
// // preloadLink.setAttribute("crossorigin", "anonymous");
// preloadLink.setAttribute("as", "fetch");
// document.head.appendChild(preloadLink);
// });
}
const loadingSvg = `background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHN0eWxlPSJtYXJnaW46YXV0bztiYWNrZ3JvdW5kOjAgMCIgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiIHZpZXdCb3g9IjAgMCAxMDAgMTAwIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCIgZGlzcGxheT0iYmxvY2siPjxjaXJjbGUgY3g9IjUwIiBjeT0iNTAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzM5Mzc0NyIgc3Ryb2tlLXdpZHRoPSIzIiByPSI0MiIgc3Ryb2tlLWRhc2hhcnJheT0iMTk3LjkyMDMzNzE3NjE1Njk4IDY3Ljk3MzQ0NTcyNTM4NTY2IiB0cmFuc2Zvcm09InJvdGF0ZSg0OC4yNjUgNTAgNTApIj48YW5pbWF0ZVRyYW5zZm9ybSBhdHRyaWJ1dGVOYW1lPSJ0cmFuc2Zvcm0iIHR5cGU9InJvdGF0ZSIgcmVwZWF0Q291bnQ9ImluZGVmaW5pdGUiIGR1cj0iNS41NTU1NTU1NTU1NTU1NTVzIiB2YWx1ZXM9IjAgNTAgNTA7MzYwIDUwIDUwIiBrZXlUaW1lcz0iMDsxIi8+PC9jaXJjbGU+PC9zdmc+")`;
@@ -167,7 +114,7 @@ function gulptasksHTML($, gulp, buildFolder, browserSync) {
font-display: swap;
src: url('${cachebust("res/fonts/GameFont.woff2")}') format('woff2');
}
#ll_fp {
font-family: GameFont;
font-size: 14px;
@@ -177,7 +124,7 @@ function gulptasksHTML($, gulp, buildFolder, browserSync) {
left: 0;
opacity: 0.05;
}
#ll_p {
display: flex;
position: fixed;
@@ -190,7 +137,7 @@ function gulptasksHTML($, gulp, buildFolder, browserSync) {
center;
align-items: center;
}
#ll_p > div {
position: absolute;
text-align: center;
@@ -201,7 +148,7 @@ function gulptasksHTML($, gulp, buildFolder, browserSync) {
font-family: 'GameFont', sans-serif;
font-size: 20px;
}
#ll_p > span {
width: 60px;
height: 60px;

View File

@@ -6,12 +6,6 @@ function requireUncached(module) {
}
function gulptasksJS($, gulp, buildFolder, browserSync) {
gulp.task("js.prettify", () => {
return gulp
.src(path.join(buildFolder, "bundle.js"))
.pipe($.jsbeautifier(require("./jsbeautify.json")))
.pipe(gulp.dest(buildFolder));
});
//// DEV
@@ -71,6 +65,7 @@ function gulptasksJS($, gulp, buildFolder, browserSync) {
gulp.task("js.staging", gulp.parallel("js.staging.transpiled", "js.staging.latest"));
//// PROD
gulp.task("js.prod.transpiled", () => {
return gulp
.src("../src/js/main.js")
@@ -167,8 +162,6 @@ function gulptasksJS($, gulp, buildFolder, browserSync) {
)
.pipe(gulp.dest(buildFolder));
});
// TODO: Tasks for te app
}
module.exports = {

View File

@@ -3,7 +3,6 @@
"version": "1.0.0",
"description": "builder",
"private": true,
"main": "main.js",
"scripts": {
"gulp": "gulp"
},
@@ -41,7 +40,6 @@
"lz-string": "^1.4.4",
"markdown-loader": "^5.1.0",
"node-sri": "^1.1.1",
"obfuscator-loader": "^1.1.2",
"phonegap-plugin-mobile-accessibility": "^1.0.5",
"promise-polyfill": "^8.1.0",
"query-string": "^6.8.1",
@@ -54,7 +52,6 @@
"uglify-template-string-loader": "^1.1.0",
"unused-files-webpack-plugin": "^3.4.0",
"webpack": "^4.43.0",
"webpack-bundle-analyzer": "^3.0.3",
"webpack-cli": "^3.1.0",
"webpack-deep-scope-plugin": "^1.6.0",
"webpack-plugin-replace": "^1.1.1",
@@ -76,8 +73,6 @@
"gulp-cache": "^1.1.3",
"gulp-cached": "^1.1.1",
"gulp-clean": "^0.4.0",
"gulp-cssbeautify": "^2.0.1",
"gulp-csslint": "^1.0.1",
"gulp-dom": "^1.0.0",
"gulp-flatten": "^0.4.0",
"gulp-fluent-ffmpeg": "^2.0.0",
@@ -85,8 +80,6 @@
"gulp-htmlmin": "^5.0.1",
"gulp-if": "^3.0.0",
"gulp-imagemin": "^7.1.0",
"gulp-javascript-obfuscator": "^1.1.5",
"gulp-jsbeautifier": "^3.0.0",
"gulp-load-plugins": "^2.0.3",
"gulp-phonegap-build": "^0.1.5",
"gulp-plumber": "^1.2.1",
@@ -104,13 +97,11 @@
"imagemin-pngquant": "^9.0.0",
"jimp": "^0.6.1",
"js-yaml": "^3.13.1",
"onesky-fetch": "^0.0.7",
"postcss-assets": "^5.0.0",
"postcss-preset-env": "^6.5.0",
"postcss-round-subpixels": "^1.2.0",
"postcss-unprefix": "^2.1.3",
"sass-unused": "^0.3.0",
"speed-measure-webpack-plugin": "^1.3.1",
"strip-json-comments": "^3.0.1",
"trim": "^0.0.1",
"webpack-stream": "^5.2.1",

View File

@@ -1,11 +1,11 @@
const packager = require("electron-packager");
const path = require("path");
const buildutils = require("./buildutils");
const { getVersion } = require("./buildutils");
const fs = require("fs");
const fse = require("fs-extra");
const execSync = require("child_process").execSync;
function gulptasksStandalone($, gulp, buildFolder) {
function gulptasksStandalone($, gulp) {
const electronBaseDir = path.join(__dirname, "..", "electron");
const tempDestDir = path.join(__dirname, "..", "tmp_standalone_files");
@@ -47,49 +47,7 @@ function gulptasksStandalone($, gulp, buildFolder) {
});
gulp.task("standalone.prepare.minifyCode", () => {
return (
gulp
.src(path.join(electronBaseDir, "*.js"))
// .pipe(
// $.terser({
// ecma: 6,
// parse: {},
// module: false,
// toplevel: true,
// keep_classnames: false,
// keep_fnames: false,
// safari10: false,
// compress: {
// arguments: false, // breaks
// drop_console: false,
// // keep_fargs: false,
// keep_infinity: true,
// passes: 2,
// module: false,
// toplevel: true,
// unsafe_math: true,
// unsafe_arrows: false,
// warnings: true,
// },
// mangle: {
// eval: true,
// keep_classnames: false,
// keep_fnames: false,
// module: false,
// toplevel: true,
// safari10: false,
// },
// output: {
// comments: false,
// ascii_only: true,
// beautify: false,
// braces: false,
// ecma: 6,
// },
// })
// )
.pipe(gulp.dest(tempDestBuildDir))
);
return gulp.src(path.join(electronBaseDir, "*.js")).pipe(gulp.dest(tempDestBuildDir));
});
gulp.task("standalone.prepare.copyGamefiles", () => {
@@ -122,15 +80,14 @@ function gulptasksStandalone($, gulp, buildFolder) {
* @param {'win32'|'linux'|'darwin'} platform
* @param {'x64'|'ia32'} arch
* @param {function():void} cb
* @param {boolean=} isRelease
*/
function packageStandalone(platform, arch, cb, isRelease = false) {
function packageStandalone(platform, arch, cb) {
const tomlFile = fs.readFileSync(path.join(__dirname, ".itch.toml"));
packager({
dir: tempDestBuildDir,
appCopyright: "Tobias Springer",
appVersion: buildutils.getVersion(),
appVersion: getVersion(),
buildVersion: "1.0.0",
arch,
platform,
@@ -164,19 +121,6 @@ function gulptasksStandalone($, gulp, buildFolder) {
'#!/usr/bin/env bash\n./shapezio --no-sandbox "$@"\n'
);
fs.chmodSync(path.join(appPath, "play.sh"), 0o775);
} else if (platform === "win32") {
// Optional: Create a playable copy. Shouldn't be required
// const playablePath = appPath + "_playable";
// fse.copySync(appPath, playablePath);
// fs.writeFileSync(path.join(playablePath, "steam_appid.txt"), "1134480");
// fs.writeFileSync(
// path.join(playablePath, "play.bat"),
// "start shapezio --dev --disable-direct-composition --in-process-gpu\r\n"
// );
// fs.writeFileSync(
// path.join(playablePath, "play_local.bat"),
// "start shapezio --local --dev --disable-direct-composition --in-process-gpu\r\n"
// );
}
if (platform === "darwin") {
@@ -226,11 +170,11 @@ function gulptasksStandalone($, gulp, buildFolder) {
);
}
gulp.task("standalone.package.prod.win64", cb => packageStandalone("win32", "x64", cb, true));
gulp.task("standalone.package.prod.win32", cb => packageStandalone("win32", "ia32", cb, true));
gulp.task("standalone.package.prod.linux64", cb => packageStandalone("linux", "x64", cb, true));
gulp.task("standalone.package.prod.linux32", cb => packageStandalone("linux", "ia32", cb, true));
gulp.task("standalone.package.prod.darwin64", cb => packageStandalone("darwin", "x64", cb, true));
gulp.task("standalone.package.prod.win64", cb => packageStandalone("win32", "x64", cb));
gulp.task("standalone.package.prod.win32", cb => packageStandalone("win32", "ia32", cb));
gulp.task("standalone.package.prod.linux64", cb => packageStandalone("linux", "x64", cb));
gulp.task("standalone.package.prod.linux32", cb => packageStandalone("linux", "ia32", cb));
gulp.task("standalone.package.prod.darwin64", cb => packageStandalone("darwin", "x64", cb));
gulp.task(
"standalone.package.prod",
@@ -240,8 +184,6 @@ function gulptasksStandalone($, gulp, buildFolder) {
"standalone.package.prod.win64",
"standalone.package.prod.linux64",
"standalone.package.prod.darwin64"
// "standalone.package.prod.win32",
// "standalone.package.prod.linux32",
)
)
);

View File

@@ -5,7 +5,7 @@ const yaml = require("gulp-yaml");
const translationsSourceDir = path.join(__dirname, "..", "translations");
const translationsJsonDir = path.join(__dirname, "..", "src", "js", "built-temp");
function gulptasksTranslations($, gulp, buildFolder) {
function gulptasksTranslations($, gulp) {
gulp.task("translations.convertToJson", () => {
return gulp
.src(path.join(translationsSourceDir, "*.yaml"))

View File

@@ -2,9 +2,8 @@
const path = require("path");
const webpack = require("webpack");
const utils = require("./buildutils");
const { getRevision, getVersion, getAllResourceImages } = require("./buildutils");
const lzString = require("lz-string");
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const CircularDependencyPlugin = require("circular-dependency-plugin");
module.exports = ({ watch = false, standalone = false }) => {
@@ -41,9 +40,9 @@ module.exports = ({ watch = false, standalone = false }) => {
G_IS_BROWSER: "true",
G_IS_STANDALONE: standalone ? "true" : "false",
G_BUILD_TIME: "" + new Date().getTime(),
G_BUILD_COMMIT_HASH: JSON.stringify(utils.getRevision()),
G_BUILD_VERSION: JSON.stringify(utils.getVersion()),
G_ALL_UI_IMAGES: JSON.stringify(utils.getAllResourceImages()),
G_BUILD_COMMIT_HASH: JSON.stringify(getRevision()),
G_BUILD_VERSION: JSON.stringify(getVersion()),
G_ALL_UI_IMAGES: JSON.stringify(getAllResourceImages()),
}),
new CircularDependencyPlugin({
@@ -60,7 +59,6 @@ module.exports = ({ watch = false, standalone = false }) => {
// set the current working directory for displaying module paths
cwd: path.join(__dirname, "..", "src", "js"),
}),
// new BundleAnalyzerPlugin()
],
module: {
rules: [

View File

@@ -2,14 +2,12 @@
const path = require("path");
const webpack = require("webpack");
const utils = require("./buildutils");
const { getRevision, getVersion, getAllResourceImages } = require("./buildutils");
const lzString = require("lz-string");
const TerserPlugin = require("terser-webpack-plugin");
const StringReplacePlugin = require("string-replace-webpack-plugin");
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const UnusedFilesPlugin = require("unused-files-webpack-plugin").UnusedFilesWebpackPlugin;
// const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");
module.exports = ({
enableAssert = false,
@@ -34,9 +32,9 @@ module.exports = ({
G_APP_ENVIRONMENT: JSON.stringify(environment),
G_HAVE_ASSERT: enableAssert ? "true" : "false",
G_BUILD_TIME: "" + new Date().getTime(),
G_BUILD_COMMIT_HASH: JSON.stringify(utils.getRevision()),
G_BUILD_VERSION: JSON.stringify(utils.getVersion()),
G_ALL_UI_IMAGES: JSON.stringify(utils.getAllResourceImages()),
G_BUILD_COMMIT_HASH: JSON.stringify(getRevision()),
G_BUILD_VERSION: JSON.stringify(getVersion()),
G_ALL_UI_IMAGES: JSON.stringify(getAllResourceImages()),
};
const minifyNames = environment === "prod";
@@ -143,9 +141,9 @@ module.exports = ({
ecma: es6 ? 6 : 5,
preamble:
"/* shapez.io Codebase - Copyright 2020 Tobias Springer - " +
utils.getVersion() +
getVersion() +
" @ " +
utils.getRevision() +
getRevision() +
" */",
},
},
@@ -164,15 +162,6 @@ module.exports = ({
cwd: path.join(__dirname, "..", "src", "js"),
patterns: ["../src/js/**/*.js"],
}),
// new webpack.SourceMapDevToolPlugin({
// filename: "[name].map",
// publicPath: "/v/" + utils.getRevision() + "/",
// }),
// new ReplaceCompressBlocks()
// new webpack.optimize.ModuleConcatenationPlugin()
// new WebpackDeepScopeAnalysisPlugin()
// new BundleAnalyzerPlugin()
],
module: {
rules: [

File diff suppressed because it is too large Load Diff