Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable glsl compress for non-mini package #2469

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ pkgs.push({ ...shaderLabPkg, verboseMode: true });
const extensions = [".js", ".jsx", ".ts", ".tsx"];
const mainFields = NODE_ENV === "development" ? ["debug", "module", "main"] : undefined;

const glslifyPlugin = glslify({
include: [/\.(glsl|gs)$/],
compress: false
});

const commonPlugins = [
resolve({ extensions, preferBuiltins: true, mainFields }),
glslify({
include: [/\.(glsl|gs)$/]
}),
glslifyPlugin,
swc(
defineRollupSwcOption({
include: /\.[mc]?[jt]sx?$/,
Expand Down Expand Up @@ -81,20 +84,23 @@ function config({ location, pkgJson, verboseMode }) {
const umdConfig = pkgJson.umd;
let file = path.join(location, "dist", "browser.js");

if (compress) {
const glslifyPluginIdx = curPlugins.findIndex((item) => item === glslifyPlugin);
curPlugins.splice(
glslifyPluginIdx,
1,
glslify({
include: [/\.(glsl|gs)$/],
compress: true
})
);
curPlugins.push(minify({ sourceMap: true }));
}

if (verboseMode) {
if (compress) {
curPlugins.push(minify({ sourceMap: true }));
file = path.join(location, "dist", "browser.verbose.min.js");
} else {
file = path.join(location, "dist", "browser.verbose.js");
}
file = path.join(location, "dist", compress ? "browser.verbose.min.js" : "browser.verbose.js");
} else {
if (compress) {
curPlugins.push(minify({ sourceMap: true }));
file = path.join(location, "dist", "browser.min.js");
} else {
file = path.join(location, "dist", "browser.js");
}
file = path.join(location, "dist", compress ? "browser.min.js" : "browser.js");
}

const umdExternal = Object.keys(umdConfig.globals ?? {});
Expand Down
Loading