diff --git a/gulp/buildutils.js b/gulp/buildutils.js index 2164bc25f..d165c8046 100644 --- a/gulp/buildutils.js +++ b/gulp/buildutils.js @@ -31,12 +31,4 @@ export function getTag() { export function getVersion() { // Use the version number specified in package.json return JSON.parse(fs.readFileSync("../package.json", "utf-8")).version; -} - -/** - * @param {string} url - * @param {string} commitHash - */ -export function cachebust(url, commitHash) { - return "/v/" + commitHash + "/" + url; -} +} \ No newline at end of file diff --git a/gulp/css.js b/gulp/css.js index 0cf48e5ba..288963b7f 100644 --- a/gulp/css.js +++ b/gulp/css.js @@ -1,5 +1,5 @@ import path from "path/posix"; -import { getRevision, cachebust } from "./buildutils.js"; +import { getRevision } from "./buildutils.js"; import gulpPostcss from "gulp-postcss"; import postcssAssets from "postcss-assets"; @@ -16,21 +16,15 @@ import gulpRename from "gulp-rename"; export default function gulptasksCSS(gulp, buildFolder, browserSync) { // The assets plugin copies the files const commitHash = getRevision(); - const postcssAssetsPlugin = enableCachebust => - postcssAssets({ - loadPaths: [path.join(buildFolder, "res", "ui")], - basePath: buildFolder, - baseUrl: ".", - cachebuster: enableCachebust - ? (filePath, urlPathname) => ({ - pathname: cachebust(urlPathname, commitHash), - }) - : "", - }); + const postcssAssetsPlugin = postcssAssets({ + loadPaths: [path.join(buildFolder, "res", "ui")], + basePath: buildFolder, + baseUrl: ".", + }); // Postcss configuration - const postcssPlugins = (prod, { cachebust = false }) => { - const plugins = [postcssAssetsPlugin(cachebust)]; + const postcssPlugins = prod => { + const plugins = [postcssAssetsPlugin]; if (prod) { plugins.unshift( postcssPresetEnv({ @@ -69,7 +63,7 @@ export default function gulptasksCSS(gulp, buildFolder, browserSync) { .pipe(gulpSassLint.failOnError()); }); - function resourcesTask({ cachebust, isProd }) { + function resourcesTask({ isProd }) { return gulp .src("../src/css/main.scss") .pipe(gulpPlumber()) @@ -82,27 +76,22 @@ export default function gulptasksCSS(gulp, buildFolder, browserSync) { ]) ) .pipe(gulpRename("async-resources.css")) - .pipe(gulpPostcss(postcssPlugins(isProd, { cachebust }))) + .pipe(gulpPostcss(postcssPlugins(isProd))) .pipe(gulp.dest(buildFolder)) .pipe(browserSync.stream()); } // Builds the css resources gulp.task("css.resources.dev", () => { - return resourcesTask({ cachebust: false, isProd: false }); + return resourcesTask({ isProd: false }); }); // Builds the css resources in prod (=minified) gulp.task("css.resources.prod", () => { - return resourcesTask({ cachebust: true, isProd: true }); - }); - - // Builds the css resources in prod (=minified), without cachebusting - gulp.task("css.resources.prod-standalone", () => { - return resourcesTask({ cachebust: false, isProd: true }); + return resourcesTask({ isProd: true }); }); - function mainTask({ cachebust, isProd }) { + function mainTask({ isProd }) { return gulp .src("../src/css/main.scss") .pipe(gulpPlumber()) @@ -115,30 +104,21 @@ export default function gulptasksCSS(gulp, buildFolder, browserSync) { }), ]) ) - .pipe(gulpPostcss(postcssPlugins(isProd, { cachebust }))) + .pipe(gulpPostcss(postcssPlugins(isProd))) .pipe(gulp.dest(buildFolder)) .pipe(browserSync.stream()); } // Builds the css main gulp.task("css.main.dev", () => { - return mainTask({ cachebust: false, isProd: false }); + return mainTask({ isProd: false }); }); // Builds the css main in prod (=minified) gulp.task("css.main.prod", () => { - return mainTask({ cachebust: true, isProd: true }); - }); - - // Builds the css main in prod (=minified), without cachebusting - gulp.task("css.main.prod-standalone", () => { - return mainTask({ cachebust: false, isProd: true }); + return mainTask({ isProd: true }); }); gulp.task("css.dev", gulp.parallel("css.main.dev", "css.resources.dev")); gulp.task("css.prod", gulp.parallel("css.main.prod", "css.resources.prod")); - gulp.task( - "css.prod-standalone", - gulp.parallel("css.main.prod-standalone", "css.resources.prod-standalone") - ); } diff --git a/gulp/gulpfile.js b/gulp/gulpfile.js index 6aed7c7b3..ad9412df5 100644 --- a/gulp/gulpfile.js +++ b/gulp/gulpfile.js @@ -251,10 +251,7 @@ for (const variant in BUILD_VARIANTS) { gulp.task(buildName + ".resourcesAndCode", gulp.parallel("step.baseResources", buildName + ".code")); - gulp.task( - buildName + ".all", - gulp.series(buildName + ".resourcesAndCode", "css.prod-standalone", "html.prod") - ); + gulp.task(buildName + ".all", gulp.series(buildName + ".resourcesAndCode", "css.prod", "html.prod")); gulp.task(buildName, gulp.series("utils.cleanup", buildName + ".all", "step.postbuild")); diff --git a/src/js/core/background_resources_loader.js b/src/js/core/background_resources_loader.js index 0dcf8561f..d967a04a6 100644 --- a/src/js/core/background_resources_loader.js +++ b/src/js/core/background_resources_loader.js @@ -6,7 +6,6 @@ import { initSpriteCache } from "../game/meta_building_registry"; import { MUSIC, SOUNDS } from "../platform/sound"; import { T } from "../translations"; import { AtlasDefinition, atlasFiles } from "./atlas_definitions"; -import { cachebust } from "./cachebust"; import { Loader } from "./loader"; import { createLogger } from "./logging"; import { Signal } from "./signal"; @@ -200,8 +199,7 @@ export class BackgroundResourcesLoader { const xhr = new XMLHttpRequest(); let notifiedNotComputable = false; - const fullUrl = cachebust(src); - xhr.open("GET", fullUrl, true); + xhr.open("GET", src, true); xhr.responseType = "arraybuffer"; xhr.onprogress = function (ev) { if (ev.lengthComputable) { @@ -225,7 +223,7 @@ export class BackgroundResourcesLoader { xhr.onloadend = function () { if (!xhr.status.toString().match(/^2/)) { - reject(fullUrl + ": " + xhr.status + " " + xhr.statusText); + reject(src + ": " + xhr.status + " " + xhr.statusText); } else { if (!notifiedNotComputable) { progressHandler(1); diff --git a/src/js/core/cachebust.js b/src/js/core/cachebust.js deleted file mode 100644 index 26be04491..000000000 --- a/src/js/core/cachebust.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Generates a cachebuster string. This only modifies the path in the browser version - * @param {string} path - */ -export function cachebust(path) { - if (G_IS_BROWSER && !G_IS_STANDALONE && !G_IS_DEV) { - return "/v/" + G_BUILD_COMMIT_HASH + "/" + path; - } - return path; -} diff --git a/src/js/core/loader.js b/src/js/core/loader.js index 29afa1235..b51406e3f 100644 --- a/src/js/core/loader.js +++ b/src/js/core/loader.js @@ -1,6 +1,5 @@ import { makeOffscreenBuffer } from "./buffer_utils"; import { AtlasSprite, BaseSprite, RegularSprite, SpriteAtlasLink } from "./sprites"; -import { cachebust } from "./cachebust"; import { createLogger } from "./logging"; /** diff --git a/src/js/game/hud/parts/interactive_tutorial.js b/src/js/game/hud/parts/interactive_tutorial.js index 734d3c7ff..4197db175 100644 --- a/src/js/game/hud/parts/interactive_tutorial.js +++ b/src/js/game/hud/parts/interactive_tutorial.js @@ -4,7 +4,6 @@ import { GameRoot } from "../../root"; import { MinerComponent } from "../../components/miner"; import { DynamicDomAttach } from "../dynamic_dom_attach"; import { TrackedState } from "../../../core/tracked_state"; -import { cachebust } from "../../../core/cachebust"; import { T } from "../../../translations"; import { enumItemProcessorTypes, ItemProcessorComponent } from "../../components/item_processor"; import { ShapeItem } from "../../items/shape_item"; @@ -190,7 +189,7 @@ export class HUDInteractiveTutorial extends BaseHUDPart { document.documentElement.setAttribute("data-tutorial-step", hintId); this.elementGif.style.backgroundImage = - "url('" + cachebust("res/ui/interactive_tutorial.noinline/" + hintId + ".gif") + "')"; + "url('res/ui/interactive_tutorial.noinline/" + hintId + ".gif')"; this.element.classList.toggle("animEven"); this.element.classList.toggle("animOdd"); if (hintId) { diff --git a/src/js/platform/browser/sound.js b/src/js/platform/browser/sound.js index 3817366a8..0beb0a35d 100644 --- a/src/js/platform/browser/sound.js +++ b/src/js/platform/browser/sound.js @@ -1,5 +1,4 @@ import { MusicInstanceInterface, SoundInstanceInterface, SoundInterface, MUSIC, SOUNDS } from "../sound"; -import { cachebust } from "../../core/cachebust"; import { createLogger } from "../../core/logging"; import { globalConfig } from "../../core/config"; @@ -23,7 +22,7 @@ class SoundSpritesContainer { } return (this.loadingPromise = new Promise(resolve => { this.howl = new Howl({ - src: cachebust("res/sounds/sfx.mp3"), + src: "res/sounds/sfx.mp3", sprite: sprites.sprite, autoplay: false, loop: false, @@ -95,7 +94,7 @@ class MusicInstance extends MusicInstanceInterface { load() { return new Promise((resolve, reject) => { this.howl = new Howl({ - src: cachebust("res/sounds/music/" + this.url + ".mp3"), + src: "res/sounds/music/" + this.url + ".mp3", autoplay: false, loop: true, html5: true, diff --git a/src/js/states/about.js b/src/js/states/about.js index 69f2e9b5a..21ab7fac3 100644 --- a/src/js/states/about.js +++ b/src/js/states/about.js @@ -1,7 +1,6 @@ import { TextualGameState } from "../core/textual_game_state"; import { T } from "../translations"; import { THIRDPARTY_URLS } from "../core/config"; -import { cachebust } from "../core/cachebust"; import { getLogoSprite } from "../core/utils"; export class AboutState extends TextualGameState { @@ -16,7 +15,7 @@ export class AboutState extends TextualGameState { getMainContentHTML() { return `
- shapez.io Logo + shapez.io Logo
${T.about.body diff --git a/src/js/states/main_menu.js b/src/js/states/main_menu.js index 148a10a77..14c23577e 100644 --- a/src/js/states/main_menu.js +++ b/src/js/states/main_menu.js @@ -1,4 +1,3 @@ -import { cachebust } from "../core/cachebust"; import { globalConfig, THIRDPARTY_URLS } from "../core/config"; import { GameState } from "../core/game_state"; import { DialogWithForm } from "../core/modal_dialog_elements"; @@ -43,11 +42,11 @@ export class MainMenuState extends GameState {