Skip to content

Commit

Permalink
feat(chore): Add attribute to adyen style tag for cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjcamposct committed Nov 15, 2024
1 parent a7ec6c0 commit 3f09ced
Showing 1 changed file with 37 additions and 12 deletions.
49 changes: 37 additions & 12 deletions enabler/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,52 @@
import { resolve } from 'path'
import { defineConfig } from 'vite'
import { resolve } from "path";
import { defineConfig } from "vite";
import cssInjectedByJsPlugin from "vite-plugin-css-injected-by-js";
import path from 'path';
import path from "path";

export default defineConfig({
plugins: [
cssInjectedByJsPlugin(),
cssInjectedByJsPlugin({
injectCodeFunction: function injectCodeCustomRunTimeFunction(
cssCode: string,
options
) {
try {
if (typeof document != "undefined") {
var elementStyle = document.createElement("style");
elementStyle.setAttribute("data-ctc-connector-styles", "");
for (const attribute in options.attributes) {
elementStyle.setAttribute(
attribute,
options.attributes[attribute]
);
}
elementStyle.appendChild(document.createTextNode(cssCode));
document.head.appendChild(elementStyle);
}
} catch (e) {
console.error("vite-plugin-css-injected-by-js", e);
}
},
}),
],
resolve: {
alias: {
'@adyen-css': path.resolve(__dirname, 'node_modules/@adyen/adyen-web/dist/es/adyen.css')
}
"@adyen-css": path.resolve(
__dirname,
"node_modules/@adyen/adyen-web/dist/es/adyen.css"
),
},
},
build: {
outDir: resolve(__dirname, 'public'),
outDir: resolve(__dirname, "public"),
lib: {
// Could also be a dictionary or array of multiple entry points
entry: resolve(__dirname, 'src/main.ts'),
name: 'Connector',
formats: ['es','umd'],
entry: resolve(__dirname, "src/main.ts"),

name: "Connector",
formats: ["es", "umd"],
// the proper extensions will be added
fileName: (format) => `connector-enabler.${format}.js`,
},
},
})
});

0 comments on commit 3f09ced

Please sign in to comment.