Skip to content

Commit

Permalink
Merge pull request #378 from metrico/fix/moment_locale_security
Browse files Browse the repository at this point in the history
fix: vite config
  • Loading branch information
lmangani authored Dec 4, 2023
2 parents e676c09 + 6e074b1 commit e5d8912
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions packages/main/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ import basicSsl from "@vitejs/plugin-basic-ssl";
import path from "path";
// https://vitejs.dev/config/

export const ignorePlugin = {
resourceRegExp: /^\.\/locale$/,
contextRegExp: /moment$/,
};

const customTransformers = [
{
test: (id) => {
return (
ignorePlugin.resourceRegExp.test(id) &&
ignorePlugin.contextRegExp.test(id)
);
},
transform: () => 'export {}',
},
];

let configOpts = {
server: {},
plugins: [
Expand All @@ -21,6 +38,11 @@ let configOpts = {
globals: true,
environment: "happy-dom",
},
optimizeDeps:{
exclude: ['moment'], // Exclude 'moment' from automatic dependency optimization
include: ['**/*.+(js|ts)'], // Include JavaScript and TypeScript files for manual dependency optimization
customTransformers
},
build: {
sourcemap: false,
rollupOptions: {
Expand All @@ -33,8 +55,6 @@ let configOpts = {
"@tanstack/react-table",
"@tanstack/match-sorter-utils",
],
moment: ["moment"],
momentTimeZone: ["moment-timezone"],
slate: ["slate", "slate-history", "slate-react"],
vendor: [
"react-responsive",
Expand All @@ -49,6 +69,7 @@ let configOpts = {
"prismjs",
"javascript-time-ago",
"json-markup",

],
reactDnd: ["react-dnd", "react-dnd-html5-backend"],
memoize: [
Expand Down Expand Up @@ -91,15 +112,17 @@ export default defineConfig(({ mode }) => {
"/api": {
target: proxyApi,
changeOrigin: env.VITE_API_BASE_URL,
secure:false,

secure: false,
},
"/loki":{target: proxyApi, changeOrigin: env.VITE_API_BASE_URL, secure:false},
"/ready":{
"/loki": {
target: proxyApi,
changeOrigin: env.VITE_API_BASE_URL,

}
secure: false,
},
"/ready": {
target: proxyApi,
changeOrigin: env.VITE_API_BASE_URL,
},
},
},
};
Expand Down

0 comments on commit e5d8912

Please sign in to comment.