next-remove-imports
TypeScript icon, indicating that this package has built-in type declarations

1.0.12 • Public • Published

next-remove-imports

NPM Downloads Build & Deploy Repo Dependents

This is a plugin for nextjs. The default behavior is to remove all .less/.css/.scss/.sass/.styl imports from all packages in node_modules.

Warning CSS Imported by a Dependency #52

Install

npm install next-remove-imports
# or
yarn add next-remove-imports

Usage

// next.config.mjs
import removeImports from 'next-remove-imports'

/** @type {function(import("next").NextConfig): import("next").NextConfig}} */
const removeImportsFun = removeImports({
  // test: /node_modules([\s\S]*?)\.(tsx|ts|js|mjs|jsx)$/,
  // matchImports: "\\.(less|css|scss|sass|styl)$"
});

export default removeImportsFun({
  webpack(config, options) {
    return config
  },
});
// next.config.js
const removeImports = require('next-remove-imports')({
  options: { },
})
module.exports = removeImports()
// next.config.js
const removeImports = require('next-remove-imports')()
module.exports = removeImports({
  webpack(config, options) {
    return config
  },
});
// next.config.js
const removeImports = require('next-remove-imports')({
  test: /node_modules([\s\S]*?)\.(tsx|ts|js|mjs|jsx)$/,
  matchImports: "\\.(less|css|scss|sass|styl)$"
});

module.exports = removeImports({
  webpack(config, options) {
    return config
  },
});
// next.config.js
const removeImports = require('next-remove-imports')();

module.exports = (phase, { defaultConfig }) => {
  return removeImports({
    ...defaultConfig
  });
};

Options

export type PluginOptions = {
  /**
   * @default "/node_modules([\s\S]*?)\.(tsx|ts|js|mjs|jsx)$/"
   */
  test?: RegExp;
  /**
   * @default "\\.(less|css|scss|sass|styl)$"
   */
  matchImports?: string;
}

License

Licensed under the MIT License.

Dependencies (3)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i next-remove-imports

    Weekly Downloads

    20,336

    Version

    1.0.12

    License

    MIT

    Unpacked Size

    6.51 kB

    Total Files

    5

    Last publish

    Collaborators

    • wcjiang