Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ima/cli-plugin-legacy-css

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ima/cli-plugin-legacy-css

Plugin for @ima/cli adding additional legacy CSS bundle output.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
0
Weekly downloads
 
Created
Source

@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');

/**
 * @type import('@ima/cli').ImaConfig
 */
module.exports = {
  plugins: [new LegacyCSSPlugin({
    /**
     * Browserslist configuration string for postcss-preset-env for legacy CSS.
     */
    cssBrowsersTarget: '>0.3%, not dead, not op_mini all',

    /**
     * Equivalent to postcss function but for legacy css,
     * when enabled with enableLegacyCss option. [optional]
     */
    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) => {
  /**
   * You have access to server event object here, so you can do detection based
   * on multiple things. We recommend using new `Sec-CH-UA` headers. Return true
   * to server legacy CSS, otherwise return false.
   */
  return true;
}, imaServer);

Dev testing

When running the application in development don't forget to run it with --writeToDisk and --legacy options.

Keywords

FAQs

Package last updated on 06 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc