Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<Spin /> error when compiling css #4915

Closed
coljung opened this issue Feb 16, 2017 · 18 comments
Closed

<Spin /> error when compiling css #4915

coljung opened this issue Feb 16, 2017 · 18 comments

Comments

@coljung
Copy link

coljung commented Feb 16, 2017

For some reason, if I include the 'Spin' component on my page, I get a webpack compiling error:

ERROR in ./~/antd/lib/spin/style/index.css
Module build failed: Error
    at NormalModule.onModuleBuildFailed (/code/node_modules/webpack-core/lib/NormalModuleMixin.js:315:19)
    at nextLoader (/code/node_modules/webpack-core/lib/NormalModuleMixin.js:270:31)
    at /code/node_modules/webpack-core/lib/NormalModuleMixin.js:292:15
    at context.callback (/code/node_modules/webpack-core/lib/NormalModuleMixin.js:148:14)
    at /code/node_modules/less-loader/index.js:68:16
    at /code/node_modules/less/lib/less/render.js:26:35
    at /code/node_modules/less/lib/less/parse.js:62:33
    at ImportVisitor.finish [as _finish] (/code/node_modules/less/lib/less/parser/parser.js:180:28)
    at ImportVisitor._onSequencerEmpty (/code/node_modules/less/lib/less/visitors/import-visitor.js:35:14)
    at ImportSequencer.tryRun (/code/node_modules/less/lib/less/visitors/import-sequencer.js:50:14)
 @ ./app/stores/StoreList.jsx 7:14-44
Child extract-text-webpack-plugin:
    chunk    {0} extract-text-webpack-plugin-output-filename 1.78 kB
        [0] ./~/css-loader!./~/postcss-loader!./~/less-loader!./app/styles/Notes.less 277 bytes {0} [built]
         + 1 hidden modules
Child extract-text-webpack-plugin:
    
    ERROR in ./~/css-loader!./~/postcss-loader!./~/less-loader!./~/antd/lib/spin/style/index.css
    Module build failed: Unrecognised input
     @ /code/node_modules/antd/lib/spin/style/index.css (line 71, column 24)
     near lines:
         /* IE6~IE9 */
         -webkit-filter: progid\:DXImageTransform\.Microsoft\.Blur(PixelRadius\=1, MakeShadow\=false);
                 filter: progid\:DXImageTransform\.Microsoft\.Blur(PixelRadius\=1, MakeShadow\=false);
webpack: Failed to compile.
GET /stores 200

I assume it has something to do with the progid IE9 rules.

Now, so far my other components work fine.

I suppose I could fix this with some sort of webpack configuration tweak ?

btw, my current webpack configuration looks like this:

{
	test: /(\.less|\.css)$/,
	loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader!less-loader'),
},

Please note that so far this is the only component causing this issue.

@benjycui
Copy link
Contributor

It's recommended to use atool-build's config https://github.com/ant-tool/atool-build/blob/master/src/getWebpackCommonConfig.js

Could you provide re-producible repo?

@afc163 afc163 closed this as completed in bc988f4 Feb 17, 2017
@coljung
Copy link
Author

coljung commented Feb 20, 2017

I updated to 2.7.2 hoping the above would fix the issue.

I still get an error when compiling:

image

@benjycui
Copy link
Contributor

benjycui commented Feb 21, 2017

The issue is that quotation marks are drop

Edit: maybe your loader doesn't support this syntax?

filter: progid\:DXImageTransform\.Microsoft\.Blur(PixelRadius\=1, MakeShadow\=false);

@benjycui benjycui reopened this Feb 21, 2017
@afc163
Copy link
Member

afc163 commented Feb 21, 2017

Could you share you webpack config?

Push you code to a git repo and I will check it later.

@coljung
Copy link
Author

coljung commented Feb 21, 2017

Here is a trimmed down copy of my current project: https://github.com/coljung/help-test/tree/master/antd-repo-help/ui-store

Also, the problem seems to be affecting other components.

I just tried using the 'loading' option for the 'Table' component, and it seems to be missing a lot of the styles associated with that as well. No errors whatsoever on my compiler or on page load.

@benjycui
Copy link
Contributor

@coljung try to separate less's config and css's config.

See: https://github.com/coljung/help-test/blob/master/antd-repo-help/ui-store/webpack.config.js#L35

You are using less-loader to process CSS, and it seems that less-loader doesn't support this syntax:

filter: progid\:DXImageTransform\.Microsoft\.Blur(PixelRadius\=1, MakeShadow\=false);

@afc163
Copy link
Member

afc163 commented Feb 22, 2017

Like what @benjycui said, try not to parse css via less-loader. https://github.com/ant-tool/atool-build/blob/master/src/getWebpackCommonConfig.js#L108-L116

@afc163 afc163 closed this as completed Feb 22, 2017
@coljung
Copy link
Author

coljung commented Feb 23, 2017

Yes, the problem is that i've tried to replicate the config from atool-build, and i get webpack error everytime.

If i use this:

{
	test: /\.css$/,
	loader: ExtractTextPlugin.extract(
        `${require.resolve('css-loader')}` +
        `?sourceMap&-autoprefixer!${require.resolve('postcss-loader')}`),
},
{
	test: /\.less$/,
	loader: ExtractTextPlugin.extract(
        `${require.resolve('css-loader')}?sourceMap&-autoprefixer!` +
        `${require.resolve('postcss-loader')}!` +
        `${require.resolve('less-loader')}?{"sourceMap":true,"modifyVars":${JSON.stringify(theme)}}`),
},

I get this errors when trying to run webpack:

image

I've tried modifying the above script multiple times, but i havent been able to find the right setup to compile properly.

@coljung
Copy link
Author

coljung commented Feb 28, 2017

well, i changed my webpack to this:

{
	test: /(\.css)$/,
	loader: ExtractTextPlugin.extract('style-loader', 'css-loader'),
},
{
	test: /(\.less)$/,
	loader: ExtractTextPlugin.extract('style-loader', `css!less?modifyVars=${JSON.stringify(theme)}`),
},
...

and the components works.

thx

@jeffz2012
Copy link

@afc163 sass isn't any better
Invalid CSS after "... filter: progid": expected "}", was ": DXImageTransform."

@lory-lu
Copy link

lory-lu commented Dec 27, 2017

the same question happened to me. I read the above solutions. only I deleted the less-loader, it can work. But, How I can work with less-loader.
attach img is my webpack.config.js css config
image

@WALLE729
Copy link

I changed webpack.config.dev.js and works, thx

@coljung
Copy link
Author

coljung commented Jan 19, 2018

An update to my current configuration using Webpack 3:

module: {
        rules: [
            {
                test: /(\.js|\.jsx)$/,
                exclude: /(node_modules)/,
                use: ['babel-loader'],
            },
            {
                test: /(\.css)$/,
                use: ExtractTextPlugin.extract({
                    fallback: [{
                        loader: 'style-loader',
                    }],
                    use: [
                        {
                            loader: 'css-loader',
                            options: {
                                minimize: true,
                            },
                        },
                    ],
                }),
            },
            {
                test: /(\.less)$/,
                use: ExtractTextPlugin.extract({
                    fallback: [{
                        loader: 'style-loader',
                    }],
                    use: [
                        'css-loader',
                        'less-loader',
                    ],
                }),
            },
            {
                test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
                loader: 'url-loader?limit=50000&name=[path][name].[ext]',
            },
        ],
    },

@WALLE729
Copy link

WALLE729 commented Jan 19, 2018 via email

@wolfsky7
Copy link

wolfsky7 commented Apr 4, 2018

把css和less 分开就好
image

@chenhebing
Copy link

chenhebing commented Jul 27, 2018

@lory-lu

I try to separate node_modules css config and my css config, then it is worked. My webpack version is 4.

{
    test: /\.css$/,
    exclude: /node_modules/,
    use: ['css-hot-loader'].concat(ExtractTextPlugin.extract({
        use: ['css-loader', {
            loader: 'postcss-loader',
            options: {
                config: {
                    path: path.resolve(__dirname, '../postcss.config.js')
                }
            }
        }, 'less-loader']
    }))
}, {
    test: /\.css$/,
    include: /node_modules/,
    use: ExtractTextPlugin.extract({
        use: ['css-loader']
    })
}

@HQidea
Copy link
Contributor

HQidea commented Oct 16, 2018

@benjycui @afc163 I think the actual problem is the escape characters (\) are redundant in this filter function. If we change this into

filter: progid:DXImageTransform.Microsoft.Blur(PixelRadius=1, MakeShadow=false);

there is no need to separate less-loader and css-loader anymore.

@panjiefeng
Copy link

the code 'filter: ~"progid:DXImageTransform.Microsoft.Blur(PixelRadius=1, MakeShadow=false)"' can be modified as 'filter: "progid:DXImageTransform.Microsoft.Blur(PixelRadius=1, MakeShadow=false)"' or 'filter: progid:DXImageTransform.Microsoft.Blur(PixelRadius=1, MakeShadow=false)' and it is ok like that. I don't understand why the source code like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants