question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack css loading

See original GitHub issue

Environment(required)

  • antd version: 2.7.4
  • OS and its version: Xubuntu 16.04
  • Browser and its version: Chromium 55.0.2883.87

What did you do? Please provide steps to re-produce your problem.

Just importing a antd component. Using babel-plugin-import 1.1.1 with:

                        ["import", {
                            "libraryName": "antd",
                            style: 'css'
                        }]

I use webpack 2 with a css loader as:

test: /\.s?css$/,
        exclude: /node_modules/,
        loaders: ["style-loader", "css-loader?sourceMap", "postcss-loader", "sass-loader?sourceMap&sourceComments"]

If I don’t include style: 'css' in babel import, webpack compiles, but ant styles are not loaded in my web application.

What do you expected?

Webpack compile with no problem. Styles are loaded

What happen?

ERROR in ./~/antd/lib/button/style/index.css
Module parse failed: /home/guillaume/Projects/bender-front-new/node_modules/antd/lib/button/style/index.css Unexpected token (1:0)
You may need an appropriate loader to handle this file type.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

18reactions
lxm7commented, Feb 21, 2018

This issue is resolved for me when i remove part of the recommended .babelrc config for ant-design

Before:

"plugins": [
    ["import", { "libraryName": "antd", "libraryDirectory": "es", "style": "css"}]
 ]

After:

"plugins": [
    ["import", { "libraryName": "antd"}]
]

webpack 3.6 antd 3.2.1

7reactions
afc163commented, Mar 15, 2017

Just don’t exclude node_modules/antd.

Read more comments on GitHub >

github_iconTop Results From Across the Web

css-loader | webpack - JS.ORG
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
How to configure CSS and CSS modules in webpack
To be able to use CSS in your webpack app, you need to set up a new loader. Out-of-the-box, webpack only understands Javascript...
Read more >
How to configure CSS Modules for webpack - LogRocket Blog
Increase the flexibility of your app's CSS components with CSS Modules and Webpack in this handy tutorial and demo app build.
Read more >
How to CSS with Webpack 5 - Setup Tutorial
CSS with Webpack in Production ... If you happen to have a Webpack configuration for development and production, you will need a different ......
Read more >
How to import CSS files into webpack? - Stack Overflow
You have to import them like any JavaScript module. That means, when the imported file is neither a relative path (starting with ../...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found