What tool is being used to minify CSS and can it be configured? #2771
-
I can't see how to configure the CSS minification. To either turn it off, or to turn off specific features. With the following CSS: ::-moz-placeholder {
color: currentColor;
opacity: 0.8;
}
:-ms-input-placeholder {
color: currentColor;
opacity: 0.8;
}
::placeholder {
color: currentColor;
opacity: 0.8;
} The resulting minified CSS is: ::-moz-placeholder,:-ms-input-placeholder,::placeholder{color:currentColor;opacity:.8} This merging of rules does not work in some browsers because if the browser encounters a pseudo-element it doesn't understand, it ignores the whole block. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
It's my understanding that vender auto-prefixing was already included in the ::placeholder {
color: currentColor;
opacity: 0.8;
} |
Beta Was this translation helpful? Give feedback.
-
Here's an interesting result. After adding The remaining issue with this is that now JS is not being minified. // svelte.config.js
export default {
preprocess: preprocess({
postcss: true
}),
kit: {
adapter: node({
out: 'build',
env: {
port: 'PORT'
},
}),
target: 'body',
files: {
lib: 'src'
},
vite: {
build: {
minify: false
}
}
}
}; // postcss.config.cjs
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
module.exports = {
plugins: [autoprefixer, cssnano]
}; ::-moz-placeholder{color:currentColor;opacity:.8}:-ms-input-placeholder{color:currentColor;opacity:.8}::placeholder{color:currentColor;opacity:.8} |
Beta Was this translation helpful? Give feedback.
-
Vite uses esbuild to minify css and javascript, so if you set |
Beta Was this translation helpful? Give feedback.
Vite uses esbuild to minify css and javascript, so if you set
minify: false
this will also disable JS minification, as you noticed.Vite does however expose a property called
build.cssTarget
, which allows you to set the (lowest) target platform your app cares about. → esbuild documentationBy default, this is set to esnext, which is probably why your css rules are unified (because the latest browsers all can handle this). Now I can't test this out for you, since I don't know which browser and which version doesn't support the merging of rules, but you can just give it a shot by setting the vite option of build.cssTarget. Let's hope esbuild knows that it shouldn't merge rules for the brows…