Answer the question
In order to leave comments, you need to log in
Is it possible to use cssNano as a function and not as a plugin?
Hello, I want to use cssNano to optimize css, but as a function, pass unoptimized css to the function, get optimized.
In the documentation I found
https://cssnano.co/docs/config-file
import postcss from "postcss";
import cssnano from "cssnano";
import litePreset from "cssnano-preset-lite";
import autoprefixer from "autoprefixer";
const preset = litePreset({ discardComments: false });
let aftercssnano = postcss([
cssnano({ preset, plugins: [autoprefixer] }),
]).process("<style>.notoptimizedhere{background: green;}</style>");
console.log(aftercssnano);
import postcss from "postcss";
^^^^^^
SyntaxError: Cannot use import statement outside a module
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question