Skip to content

Instantly share code, notes, and snippets.

@M-Drummond
Created March 3, 2024 22:15
Show Gist options
  • Save M-Drummond/cc90c2304f35d4a4e31fa8d08cbb2ba7 to your computer and use it in GitHub Desktop.
Save M-Drummond/cc90c2304f35d4a4e31fa8d08cbb2ba7 to your computer and use it in GitHub Desktop.
ViteJS Config for Wordpress Theme Dev
import legacy from '@vitejs/plugin-legacy'
import ViteRestart from 'vite-plugin-restart';
import 'dotenv/config'
import tailwindConfig from './tailwind.config';
// https://vitejs.dev/config/
export default ({ command }) => ({
base: command === 'serve' ? '' : '/dist/',
build: {
manifest: true,
outDir: 'wp-content/themes/themedir/dist',
rollupOptions: {
input: {
app: 'src/js/app.ts',
},
output: {
entryFileNames: `assets/[name].js`,
chunkFileNames: `assets/[name].js`,
assetFileNames: `assets/[name].[ext]`
}
},
},
css: {
postcss: {
plugins: [
require('tailwindcss')({
config: 'tailwind.config.js'
})
]
}
},
plugins: [
// vue(),
legacy({
targets: ['defaults', 'not IE 11']
}),
ViteRestart({
reload: [
'wp-content/themes/themedir/**/*',
'wp-content/themes/themedir/*',
],
}),
],
});
console.log('vite config loaded');
console.log( tailwindConfig.content );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment