statamic + vite : hmr reloading control panel #11357
Replies: 4 comments 1 reply
-
Change But that would disable that for your front-end files. You might want to consider two separate vite.config.js files. vite -c vite-control-panel.config.js |
Beta Was this translation helpful? Give feedback.
-
I'm having the same problem, I found Could you show a working version using the This is my vite file
|
Beta Was this translation helpful? Give feedback.
-
I do this, works well. Separate config, hot file and build destination: import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue2 from '@vitejs/plugin-vue2';
export default defineConfig({
plugins: [
laravel({
hotFile: 'public/hot-cp',
buildDirectory: 'build-cp',
input: [
'resources/js/cp.js',
],
}),
vue2(),
],
}); Statamic::vite('app', [
'hotFile' => __DIR__.'/../../public/hot-cp',
'buildDirectory' => 'build-cp',
'input' => [
'resources/js/cp.js',
],
]); Then in package.json set up separate scripts: "scripts": {
"dev": "vite",
"build": "vite build",
"dev-cp": "vite --config vite-cp.config.js",
"build-cp": "vite build --config vite-cp.config.js",
}, I've created a demo repo set up with this approach: https://github.com/jacksleight/statamic-vite-split-test |
Beta Was this translation helpful? Give feedback.
-
Thanks, this is what I've done...
Statamic::vite('app', [
'hotFile' => __DIR__.'/../../public/hot-cp',
'buildDirectory' => 'build-cp',
'input' => [
'resources/js/cp.js',
'resources/css/cp.css',
],
]);
import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
// import vue2 from '@vitejs/plugin-vue2';
export default defineConfig({
plugins: [
laravel({
input: [
"resources/css/site.css",
"resources/js/site.js",
"resources/css/vendors/splide-default.min.css",
"resources/js/vendors/cookies.js",
// Control Panel assets.
// https://statamic.dev/extending/control-panel#adding-css-and-js-assets
// "resources/css/cp.css",
// "resources/js/cp.js",
],
refresh: true,
}),
// vue2(),
],
}); The second vite config, import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
// import vue2 from "@vitejs/plugin-vue2";
export default defineConfig({
plugins: [
laravel({
hotFile: "public/hot-cp",
buildDirectory: "build-cp",
input: [
'resources/js/cp.js',
'resources/css/cp.css',
],
}),
// vue2(),
],
});
Added the new commands to
But when I run |
Beta Was this translation helpful? Give feedback.
-
Hi, am I the only one having the issue that the control panel reloads each time I make content change or code change ? my wite config has this but I can't get it to work to exclude cp :
Beta Was this translation helpful? Give feedback.
All reactions