Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.
This repository was archived by the owner on May 29, 2019. It is now read-only.

ETP can't works with oneOf configuration in webpack? #705

Closed
@kimown

Description

@kimown

Hi, thanks ETP and your guys work, it helps me a lot in my daily work.

I am try to combine css modules and postcss, here is solution I found, the configuration like this
css-modules/css-modules#65 (comment), use oneOf
and querystring ?raw to distinct local scope css file and global scope css file.
So my webpack.config.js is this:

{
        test: /\.css$/,
        // https://github.com/css-modules/css-modules/pull/65#issuecomment-355078216
        oneOf: [{
          resourceQuery: /^\?raw$/,
          use: ExtractTextPlugin.extract([
            // 'style-loader',
            'css-loader',
            'postcss-loader'
          ])
        }, {
          use: ExtractTextPlugin.extract([
            // 'style-loader',
            {
              loader: 'css-loader',
              options: {
                modules: true,
                localIdentName: '[path][name]__[local]--[hash:base64:5]',
                importLoaders: 1
              }
            },
            // https://webpack.js.org/loaders/postcss-loader/#src/components/Sidebar/Sidebar.jsx
            'postcss-loader'
          ])
        }]
      }

Here is an reproduce example:

demo.zip

unzip demo.zip -d demo
cd demo
npm i // seems a lot of node_modules...
npm run build

then console print errors,

ERROR in ./src/index.css
Module build failed: Error: "extract-text-webpack-plugin" loader is used without the corresponding plugin, refer to https://github.com/webpack/extract-text-webpack-plugin for the usage example

image

I searched issue, seems oneOf already have a solution #483 (comment)

did I made a mistake about configuration?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions