@ima/cli-plugin-legacy-css
Adds ability to built another CSS bundle with client
bundle with different postcss-present-env
configuration. This allows you to build 2 bundles with different amount of CSS polyfillying (which results in larger file size) and serve the best version to targetted browser.
Installation
npm install @ima/cli-plugin-legacy-css -D
Usage
const { LegacyCSSPlugin } = require('@ima/cli-plugin-legacy-css');
module.exports = {
plugins: [new LegacyCSSPlugin({
cssBrowsersTarget: '>0.3%, not dead, not op_mini all',
postcss: (config) => config,
})],
};
Server hook
You need to define your own detector for the server hook. It accepts callback function which should return true for legacy CSS to be served.
const { createIMAServer } = require('@ima/server');
const { createLegacyCssHook } = require('@ima/cli-plugin-legacy-css/server');
const imaServer = createIMAServer();
createLegacyCssHook((event) => {
return true;
}, imaServer);
Dev testing
When running the application in development don't forget to run it with --writeToDisk
and --legacy
options.