37 lines
877 B
TypeScript
37 lines
877 B
TypeScript
import { defineConfig, loadEnv } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import htmlPlugin from "vite-plugin-html-config"
|
|
|
|
const headScripts = []
|
|
|
|
export default defineConfig(
|
|
|
|
({ command, mode }) => {
|
|
|
|
console.log(command)
|
|
const env = loadEnv(mode, process.cwd(), '')
|
|
let headScript = `console.log('analyntics will be here');`
|
|
// if (env.NODE_ENV=='production'){
|
|
if (command=='build'){
|
|
headScripts.push(
|
|
{
|
|
src: 'https://anl.wst74.ru/script.js',
|
|
'data-website-id': '88168e43-88d4-4c29-bcb0-4c0cc878e7bb'
|
|
|
|
})
|
|
}
|
|
else headScripts.push(headScript)
|
|
|
|
return {
|
|
// vite config
|
|
define: {
|
|
__APP_ENV__: JSON.stringify(env.APP_ENV),
|
|
},
|
|
plugins: [
|
|
react(),
|
|
htmlPlugin({title: 'custom title', headScripts: headScripts})
|
|
]
|
|
}
|
|
}
|
|
|
|
) |