mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-13 18:21:51 +00:00
commit 176343785eea110e529f26027bf864ae04068384
Author: EmeraldBlock <yygengjunior@gmail.com>
Date: Fri Dec 8 23:03:51 2023 -0600
update readme
commit 8c1c3a0c47f5125126cb00d32a48f4f9344a3fb3
Author: EmeraldBlock <yygengjunior@gmail.com>
Date: Fri Dec 8 23:00:05 2023 -0600
fix bugs
commit ea881e68c693a447e0698a3a6e7cfb1f25ccb6cc
Author: EmeraldBlock <yygengjunior@gmail.com>
Date: Fri Dec 8 22:46:46 2023 -0600
expose all tasks with old api
commit fa6d7a3920ff573eadb61425cc077f0e00406164
Author: EmeraldBlock <yygengjunior@gmail.com>
Date: Fri Dec 8 21:51:20 2023 -0600
switch to exported gulp tasks
commit 348b19a0171e65400bcd434cf7b7432f3488a411
Author: EmeraldBlock <yygengjunior@gmail.com>
Date: Mon Nov 20 22:55:38 2023 -0600
parallelize dev build
commit 56de73e2d18d20e5ea7202afc021573a746e5012
Author: EmeraldBlock <yygengjunior@gmail.com>
Date: Mon Nov 20 20:44:10 2023 -0600
use promises in gulpfile
commit 6ab54372482f26acb4769428eefbdc48240a12a1
Author: EmeraldBlock <yygengjunior@gmail.com>
Date: Mon Nov 20 20:33:36 2023 -0600
make java -version print again
commit b0e4cf57bdc404bb3b0e45b7b233d5f7648c800e
Author: EmeraldBlock <yygengjunior@gmail.com>
Date: Mon Nov 20 20:14:13 2023 -0600
use promises for gulp tasks
121 lines
3.5 KiB
JavaScript
121 lines
3.5 KiB
JavaScript
import path from "path/posix";
|
|
import gulp from "gulp";
|
|
import { getRevision } from "./buildutils.js";
|
|
import { buildFolder, browserSync } from "./config.js";
|
|
|
|
import gulpPostcss from "gulp-postcss";
|
|
import postcssAssets from "postcss-assets";
|
|
import postcssPresetEnv from "postcss-preset-env";
|
|
import postcssRoundSubpixels from "postcss-round-subpixels";
|
|
import postcssCriticalSplit from "postcss-critical-split";
|
|
import cssMqpacker from "css-mqpacker";
|
|
import cssnano from "cssnano";
|
|
import gulpSassLint from "gulp-sass-lint";
|
|
import gulpDartSass from "gulp-dart-sass";
|
|
import gulpPlumber from "gulp-plumber";
|
|
import gulpRename from "gulp-rename";
|
|
|
|
// The assets plugin copies the files
|
|
const commitHash = getRevision();
|
|
const postcssAssetsPlugin = postcssAssets({
|
|
loadPaths: [path.join(buildFolder, "res", "ui")],
|
|
basePath: buildFolder,
|
|
baseUrl: ".",
|
|
});
|
|
|
|
// Postcss configuration
|
|
const postcssPlugins = prod => {
|
|
const plugins = [postcssAssetsPlugin];
|
|
if (prod) {
|
|
plugins.unshift(
|
|
postcssPresetEnv({
|
|
browsers: ["> 0.1%"],
|
|
})
|
|
);
|
|
|
|
plugins.push(
|
|
cssMqpacker({
|
|
sort: true,
|
|
}),
|
|
cssnano({
|
|
preset: [
|
|
"advanced",
|
|
{
|
|
cssDeclarationSorter: false,
|
|
discardUnused: true,
|
|
mergeIdents: false,
|
|
reduceIdents: true,
|
|
zindex: true,
|
|
},
|
|
],
|
|
}),
|
|
postcssRoundSubpixels()
|
|
);
|
|
}
|
|
return plugins;
|
|
};
|
|
|
|
// Performs linting on css
|
|
export function lint() {
|
|
return gulp
|
|
.src(["../src/css/**/*.scss"])
|
|
.pipe(gulpSassLint({ configFile: ".sasslint.yml" }))
|
|
.pipe(gulpSassLint.format())
|
|
.pipe(gulpSassLint.failOnError());
|
|
}
|
|
|
|
function resourcesTask({ isProd }) {
|
|
return gulp
|
|
.src("../src/css/main.scss")
|
|
.pipe(gulpPlumber())
|
|
.pipe(gulpDartSass.sync().on("error", gulpDartSass.logError))
|
|
.pipe(
|
|
gulpPostcss([
|
|
postcssCriticalSplit({
|
|
blockTag: "@load-async",
|
|
}),
|
|
])
|
|
)
|
|
.pipe(gulpRename("async-resources.css"))
|
|
.pipe(gulpPostcss(postcssPlugins(isProd)))
|
|
.pipe(gulp.dest(buildFolder))
|
|
.pipe(browserSync.stream());
|
|
}
|
|
|
|
export const resources = {
|
|
// Builds the css resources
|
|
dev: () => resourcesTask({ isProd: false }),
|
|
|
|
// Builds the css resources in prod (=minified)
|
|
prod: () => resourcesTask({ isProd: true }),
|
|
};
|
|
|
|
function mainTask({ isProd }) {
|
|
return gulp
|
|
.src("../src/css/main.scss")
|
|
.pipe(gulpPlumber())
|
|
.pipe(gulpDartSass.sync().on("error", gulpDartSass.logError))
|
|
.pipe(
|
|
gulpPostcss([
|
|
postcssCriticalSplit({
|
|
blockTag: "@load-async",
|
|
output: "rest",
|
|
}),
|
|
])
|
|
)
|
|
.pipe(gulpPostcss(postcssPlugins(isProd)))
|
|
.pipe(gulp.dest(buildFolder))
|
|
.pipe(browserSync.stream());
|
|
}
|
|
|
|
export const main = {
|
|
// Builds the css main
|
|
dev: () => mainTask({ isProd: false }),
|
|
|
|
// Builds the css main in prod (=minified)
|
|
prod: () => mainTask({ isProd: true }),
|
|
};
|
|
|
|
export const dev = gulp.parallel(main.dev, resources.dev);
|
|
export const prod = gulp.parallel(main.prod, resources.prod);
|