0.1.10 • Published 4 years ago

es6-css-loader v0.1.10

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

ES6 CSS Loader

An attempt to support ES6 import/export for style-loader, mini-css-extract-plugin

Installation

Via npm:

npm install es6-css-loader --save-dev

Via yarn:

yarn add -D es6-css-loader

Usage

For style-loader

const { styleLoader, cssLoader } = require('es6-css-loader');

const webpackConfig = {
  ...
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          {
            loader: styleLoader,
            options: {
              // same as the current `style-loader`
            },
          }
          {
            loader: 'css-loader',
            options: {
              ...
            }
          }
        ]
      }
    ]
  }
}

For mini-css-extract-plugin

const { miniCssExtractLoader, MiniCssExtractPlugin } = require('es6-css-loader');

const webpackConfig = {
  ...
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          miniCssExtractLoader,
          {
            loader: 'css-loader',
            options: {
              ...
            }
          }
        ]
      }
    ]
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: "[name].css",
      chunkFilename: "[id].css"
    })
  ],
}

In your js/ts files

import { selectors you want to use } from './style.css'

✍️ Why not css-loader? css-loader is usually used along with style-loader or mini-css-extract-plugin, therefore, supporting for a first pitching loader is what we need.

✍️ According to this webpack issue, webpack team will support es6 import/export by default in the upcomming release, but I don't think it will be soon, therefore, this plugin is the hacky solution (super ugly) and it might potentially break something in your codebase, therefore, using it with caution.

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago