0

I am using webpack, I can "import" the css file without error, but the css is not exported in the final product.

Webpack excerpt:

 module: {
    loaders: [
      {test: /\.css$/,loader: 'css-loader'},
      {test: /\.scss$/,loader: ExtractTextPlugin.extract('css-loader!sass-loader')},
      {test: /\.js$/, loader: 'babel-loader', include},
      {test: /\.json$/, loader: 'json', include},
      {test: /\.jpe?g$|\.gif$|\.png$/i, loader: "file-loader" },
    ]
  },

Run:

npm install hopscotch

Code:

import 'hopscotch/dist/css/hopscotch.css';

2 Answers 2

1

I was not using extract for the css files...

{test: /\.css$/,loader: 'css-loader'},

Should be:

{test: /\.css$/,loader: ExtractTextPlugin.extract('css-loader')},
Sign up to request clarification or add additional context in comments.

Comments

0

In addition to your answer, you also need to add ExtractTextPlugin to the plugins array to define where to export the extracted CSS.

module: {
  loaders: [
    {test: /\.css$/,loader: ExtractTextPlugin.extract('css-loader')},
    {test: /\.scss$/,loader: ExtractTextPlugin.extract('css-loader!sass-loader')},
    {test: /\.js$/, loader: 'babel-loader', include},
    {test: /\.json$/, loader: 'json', include},
    {test: /\.jpe?g$|\.gif$|\.png$/i, loader: "file-loader" },
  ]
  plugins: [
    new ExtractTextPlugin({ filename: 'style.css' }),
  ],
},

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.