Skip to content

Commit

Permalink
Merge pull request #55 from Namide/feature/web-workers
Browse files Browse the repository at this point in the history
Feature/web workers
  • Loading branch information
Namide authored Oct 11, 2024
2 parents 012f065 + a3df8ca commit bfcac4e
Show file tree
Hide file tree
Showing 16 changed files with 915 additions and 393 deletions.
5 changes: 3 additions & 2 deletions conf/tsconfig.type.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"allowJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"isolatedModules": false
"isolatedModules": false,
"types": ["vite/client"]
},
"files": ["../src/extractColors.ts"]
"files": ["../src/extractColors.ts", "../src/workerWrapper.ts"]
}
2 changes: 1 addition & 1 deletion conf/tsconfig.vite.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"lib": ["ESNext", "DOM"],
"noEmit": true
},
"files": ["../src/extractColors.ts"],
"files": ["../src/extractColors.ts", "../src/workerWrapper.ts"],
"include": ["../src/**/*", "../tests/**/*"]
}
94 changes: 47 additions & 47 deletions conf/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
import path from "path";
import { defineConfig } from "vite";
import { UserConfig } from "vite";

export default () => {
return defineConfig({
define: {
// __DEV__: JSON.stringify(`process.env.NODE_ENV !== "production"`)
export default {
define: {
// __DEV__: JSON.stringify(`process.env.NODE_ENV !== "production"`)
},
build: {
sourcemap: true,
lib: {
entry: path.resolve(__dirname, "../src/extractColors.ts"),
name: "ExtractColors",
fileName: (format) =>
`extract-colors.${format === "es" ? "mjs" : format}`,
formats: ["cjs", "es"],
},
build: {
sourcemap: true,
lib: {
entry: path.resolve(__dirname, "../src/extractColors.ts"),
name: "ExtractColors",
fileName: (format) =>
`extract-colors.${format === "es" ? "mjs" : format}`,
formats: ["cjs", "es"],
},
minify: "terser",
terserOptions: {
mangle: {
properties: {
reserved: [
"pixels",
"distance",
"colorValidator",
"hueDistance",
"saturationDistance",
"lightnessDistance",
"crossOrigin",
"hex",
"red",
"green",
"blue",
"area",
"hue",
"saturation",
"lightness",
"intensity",
"extractColors",
"extractColorsFromImage",
"extractColorsFromImageData",
"extractColorsFromSrc",
],
},
minify: "terser",
terserOptions: {
mangle: {
properties: {
reserved: [
"pixels",
"distance",
"colorValidator",
"hueDistance",
"saturationDistance",
"lightnessDistance",
"crossOrigin",
"requestMode",
"hex",
"red",
"green",
"blue",
"area",
"hue",
"saturation",
"lightness",
"intensity",
"extractColors",
"extractColorsFromImage",
"extractColorsFromImageData",
"extractColorsFromImageBitmap",
"extractColorsFromSrc",
],
},
},
rollupOptions: {
output: {
dir: "./lib",
},
},
rollupOptions: {
output: {
dir: "./lib",
},
},
});
};
},
} satisfies UserConfig;
21 changes: 21 additions & 0 deletions conf/vite.config.worker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import path from "path";
import { UserConfig } from "vite";
import conf from "./vite.config";

export default {
...conf,
// define: {
// __DEV__: JSON.stringify(`process.env.NODE_ENV !== "production"`),
// },
build: {
...conf.build,
emptyOutDir: false,
lib: {
entry: path.resolve(__dirname, "../src/workerWrapper.ts"),
name: "ExtractColors",
fileName: (format) =>
`worker-wrapper.${format === "es" ? "mjs" : format}`,
formats: ["cjs", "es"],
},
},
} satisfies UserConfig;
Loading

0 comments on commit bfcac4e

Please sign in to comment.