build prod

This commit is contained in:
Zakhar 2026-08-28 10:06:59 +03:00
parent 5d15e740fc
commit 3ce3a27e78

View File

@ -5,10 +5,23 @@ import fs from 'node:fs';
export default defineConfig(({mode}) => ({
plugins: [
react(),
{
name: 'add-nonce-back',
transformIndexHtml(html) {
const nonce = '**MY_PRETTY_CSP_NONCE**';
return html.replace(
/<script\s+type="module"\s+crossorigin\s+src="\/autocart\.js"\s*>/,
(match) => {
return `<script type="module" crossorigin nonce="${nonce}" src="/autocart.js">`;
}
);
},
},
mode === 'production' && {
name: 'copy-html-root',
closeBundle() {
fs.copyFileSync('dist/src/template.html', 'dist/auto_cart.html');
fs.copyFileSync('dist/src/template.html', 'auto_cart.html');
fs.copyFileSync('dist/autocart.js', 'autocart.js');
},
},
],