Skip to content

Commit

Permalink
Disable glsl compress for non-mini package (#2469)
Browse files Browse the repository at this point in the history
* feat: disable glsl compress for non mini package
  • Loading branch information
Sway007 authored Dec 18, 2024
1 parent 24abef3 commit aa07cd8
Showing 1 changed file with 21 additions and 15 deletions.
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

0 comments on commit aa07cd8

Please sign in to comment.