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

feat(chore): Add attribute to adyen style tag for cleanup #260

Merged
merged 1 commit into from
Nov 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
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`,
},
},
})
});
Loading