8000 GitHub - webpack-contrib/css-loader: CSS Loader
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

webpack-contrib/css-loader

Repository files navigation

npm node tests coverage discussion size

css-loader

The css-loader interprets @import and url() like import/require() and resolves them.

Getting Started

Warning

To use the latest version of css-loader, webpack@5 is required

To begin, you'll need to install css-loader:

npm install --save-dev css-loader

or

yarn add -D css-loader

or

pnpm add -D css-loader

Then, add the loader to your webpack configuration. For example:

file.js

import * as css from "file.css";

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: ["style-loader", "css-loader"],
      },
    ],
  },
};

Finally, run webpack using the method you normally use (e.g., via CLI or an npm script).

If you need to extract CSS into a separate file (i.e. do not store CSS in a JS module), consider using the recommend example.

Options

url