vite-plugin-react
vite-plugin-react copied to clipboard
inject css in shadowDom
Describe the bug
I have vite config
import react from '@vitejs/plugin-react';
import * as path from 'path';
import { defineConfig, splitVendorChunkPlugin } from 'vite';
import htmlPlugin from 'vite-plugin-html-config';
import { dependencies } from './package.json';
const exclVendors = ['react', 'react-router-dom', 'react-dom'];
function renderChunks(deps: Record<string, string>) {
let chunks = {};
Object.keys(deps).forEach((key) => {
if (exclVendors.includes(key)) return;
chunks[key] = [key];
});
return chunks;
}
// https://vitejs.dev/config/
export default defineConfig({
server: {
port: 8082
},
envPrefix: 'APP_',
resolve: {
alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
},
plugins: [
react(),
htmlPlugin({ favicon: './src/assets/logo.svg' }),
splitVendorChunkPlugin(),
],
build: {
sourcemap: false,
rollupOptions: {
output: {
manualChunks: {
...renderChunks(dependencies),
},
},
},
},
});
I want create app in shadow Dom.
The application is built in the shadow Dom but the css is added to the head.
How to add all css to shadow Dom?
In esbuild this is done by esbuild-css-modules-plugin, but I haven’t found how to do the same in vite
Reproduction
http://
Steps to reproduce
I have vite config
import react from '@vitejs/plugin-react';
import * as path from 'path';
import { defineConfig, splitVendorChunkPlugin } from 'vite';
import htmlPlugin from 'vite-plugin-html-config';
import { dependencies } from './package.json';
const exclVendors = ['react', 'react-router-dom', 'react-dom'];
function renderChunks(deps: Record<string, string>) {
let chunks = {};
Object.keys(deps).forEach((key) => {
if (exclVendors.includes(key)) return;
chunks[key] = [key];
});
return chunks;
}
// https://vitejs.dev/config/
export default defineConfig({
server: {
port: 8082
},
envPrefix: 'APP_',
resolve: {
alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
},
plugins: [
react(),
htmlPlugin({ favicon: './src/assets/logo.svg' }),
splitVendorChunkPlugin(),
],
build: {
sourcemap: false,
rollupOptions: {
output: {
manualChunks: {
...renderChunks(dependencies),
},
},
},
},
});
I want create app in shadow Dom.
The application is built in the shadow Dom but the css is added to the head.
How to add all css to shadow Dom?
In esbuild this is done by esbuild-css-modules-plugin, but I haven’t found how to do the same in vite
System Info
I have vite config
import react from '@vitejs/plugin-react';
import * as path from 'path';
import { defineConfig, splitVendorChunkPlugin } from 'vite';
import htmlPlugin from 'vite-plugin-html-config';
import { dependencies } from './package.json';
const exclVendors = ['react', 'react-router-dom', 'react-dom'];
function renderChunks(deps: Record<string, string>) {
let chunks = {};
Object.keys(deps).forEach((key) => {
if (exclVendors.includes(key)) return;
chunks[key] = [key];
});
return chunks;
}
// https://vitejs.dev/config/
export default defineConfig({
server: {
port: 8082
},
envPrefix: 'APP_',
resolve: {
alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
},
plugins: [
react(),
htmlPlugin({ favicon: './src/assets/logo.svg' }),
splitVendorChunkPlugin(),
],
build: {
sourcemap: false,
rollupOptions: {
output: {
manualChunks: {
...renderChunks(dependencies),
},
},
},
},
});
I want create app in shadow Dom.
The application is built in the shadow Dom but the css is added to the head.
How to add all css to shadow Dom?
In esbuild this is done by esbuild-css-modules-plugin, but I haven’t found how to do the same in vite
### Used Package Manager
npm
### Logs
I have vite config
import react from '@vitejs/plugin-react'; import * as path from 'path'; import { defineConfig, splitVendorChunkPlugin } from 'vite'; import htmlPlugin from 'vite-plugin-html-config'; import { dependencies } from './package.json';
const exclVendors = ['react', 'react-router-dom', 'react-dom']; function renderChunks(deps: Record<string, string>) { let chunks = {}; Object.keys(deps).forEach((key) => { if (exclVendors.includes(key)) return; chunks[key] = [key]; }); return chunks; }
// https://vitejs.dev/config/ export default defineConfig({ server: { port: 8082 }, envPrefix: 'APP_', resolve: { alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }], }, plugins: [ react(), htmlPlugin({ favicon: './src/assets/logo.svg' }), splitVendorChunkPlugin(), ], build: { sourcemap: false, rollupOptions: { output: { manualChunks: { ...renderChunks(dependencies), }, }, }, }, });
I want create app in shadow Dom.
The application is built in the shadow Dom but the css is added to the head.
How to add all css to shadow Dom?
In esbuild this is done by esbuild-css-modules-plugin, but I haven’t found how to do the same in vite