Hey Everyone,
I'm having a problem with vite build --watch.
I'm trying to implement vite into a neos cms setup. On building, a .js file and a .css file are generated and integrated into the cms. The initial build builds everything fine, and all my styles are in order and work.
However, when i edit a file located under:
styles > sass > components > file.scss
that is being imported via @use into styles > sass > index.scss
the build watcher notices a change, but does not change the compiled index.css.
When i change the index.scss directly, the index.css correctly compiles.
Any help would be greatly appreciated 🙂
github repo to test the issue: https://github.com/mar0yan/vite-build-scss-issue-demo
This is my vite config:
import { defineConfig } from 'vite';
import path from 'path';
import tailwindcss from '@tailwindcss/postcss';
export default defineConfig({
plugins: [
],
css: {
postcss: {
plugins: [
tailwindcss(),
],
},
},
server: {
hmr: false,
},
build: {
manifest: true,
outDir: path.resolve(__dirname, 'Resources/Public'),
emptyOutDir: true,
watch: {
include: [
'src/javascript/*.js',
'src/sass/*.scss',
'src/sass/**/*.scss',
'Resources/Private/**'
],
},
rollupOptions: {
input: {
'index-css': path.resolve(__dirname, 'src/sass/index.scss'),
'critical-css': path.resolve(__dirname, 'src/sass/critical.scss'),
main: path.resolve(__dirname, 'src/javascript/main.js'),
},
output: {
assetFileNames: (assetInfo) => {
if (assetInfo.name.endsWith('.css')) {
// return 'styles/[name].[hash].css'; // Save all CSS files in "styles" folder
return 'styles/[name].css'; // Save all CSS files in "styles" folder
}
},
entryFileNames: 'javascripts/[name].js',
dir: 'Resources/Public',
},
},
},
});