admin管理员组文章数量:1279125
I have a Neos CMS project which has a small preact project inside of it. The bundled preact JS code should not always be rendered, but only when a specific element is rendered. For this reason, I can't bundle all my JavaScript into one and need two Vite processes.
Now the problem: The Vite processes of course don't know of each other and use the same function and variable names for the minification, which, of course, breaks everything.
This is my configuration:
import {defineConfig} from 'vite';
import FullReload from 'vite-plugin-full-reload';
import 'dotenv/config';
const sitePackageName = process.env.SITE_PACKAGE_NAME;
export default defineConfig(({command}) => {
const base = command === 'build' ? `/_Resources/Static/Packages/${sitePackageName}/Build` : '';
return {
base: base,
build: {
manifest: false,
rollupOptions: {
input: [
`./DistributionPackages/${sitePackageName}/Resources/Private/JavaScript/main.js`,
],
output: {
entryFileNames: `Assets/[name].js`,
chunkFileNames: `Assets/[name].js`,
assetFileNames: `Assets/[name].[ext]`,
},
},
outDir: `./DistributionPackages/${sitePackageName}/Resources/Public/Build`,
assetsDir: '',
},
publicDir: false,
server: {
strictPort: true,
port: 3000,
origin: 'http://localhost:3000',
},
plugins: [
FullReload([
`./DistributionPackages/${sitePackageName}/**/*.{fusion,css,js}`,
], {
delay: 1000,
}),
]
};
});
The second configuration is this one for the preact project:
import { defineConfig } from 'vite';
import preact from '@preact/preset-vite';
import svgr from "vite-plugin-svgr";
export default defineConfig({
plugins: [preact(), svgr()],
build: {
rollupOptions: {
output: {
entryFileNames: 'index.js',
assetFileNames: 'index.css'
},
}
}
});
This builds two javascript files, that, when included together, always throw errors, because they both use the same variable names.
本文标签: reactjsMultiple Vite processes overwriting each other39s javascript variablesStack Overflow
版权声明:本文标题:reactjs - Multiple Vite processes overwriting each other's javascript variables - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741256266a2366731.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论