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

Icon animation are not imported #318

Closed
pybuche opened this issue Apr 3, 2019 · 4 comments
Closed

Icon animation are not imported #318

pybuche opened this issue Apr 3, 2019 · 4 comments

Comments

@pybuche
Copy link

pybuche commented Apr 3, 2019

Hi,

I used this plugin to help me decrease my bundle size, but it results in having missing imports.
At least, I noticed it with Button component, while using the loading prop.

My Button:

import React from 'react';
import PropTypes from 'prop-types';
import { Button as AntButton } from 'antd';

import 'antd/lib/style/core/iconfont.less'; // Need this import for the loading spinner to actually spin
import 'app/assets/style/atoms/button.scss';

const Button = ({ children, ...props }) => (
    <AntButton className="btn" size="large" type="primary" {...props}>
        <span>{children}</span>
    </AntButton>
);

Button.propTypes = {
    children: PropTypes.node,
};

export default Button;

And my .babelrc:

{
    "presets": [
        "babel-preset-env",
        "babel-preset-react",
    ],
    "plugins": [
        "macros",
        "transform-class-properties",
        "transform-object-rest-spread",
        ["babel-plugin-styled-components", { "ssr": true }],
        ["import", { "libraryName": "antd", "style": true }]
    ],
    "ignore": ["node_modules", "public/dist"]
}

Any idea how I could fix it?
Thx!

@afc163
Copy link
Contributor

afc163 commented Apr 3, 2019

- import 'antd/lib/style/core/iconfont.less';
+ import 'antd/lib/button/style';

@afc163 afc163 closed this as completed Apr 3, 2019
@pybuche
Copy link
Author

pybuche commented Apr 3, 2019

But shouldn't the babel-import-plugin do that for me ? With the .babelrc line:

["import", { "libraryName": "antd", "style": true }]

I tried it anyway and it doesn't change my problem. antd/lib/button/style is already imported in the transpiled files, but the icon spinning animation file is not :/

@afc163
Copy link
Contributor

afc163 commented Apr 3, 2019

Could you provide a reproduce github repo?

@afc163 afc163 reopened this Apr 3, 2019
@pybuche
Copy link
Author

pybuche commented Apr 3, 2019

Ok, I found the problem.

I did that ant-design/ant-design#4331 (comment) to avoid having global style leak on my project.
Thus the global iconfont & motion less files where not imported...

I switched to a different strategy that is this one ant-design/ant-design#4331 (comment)
I hope we can figure out a solution later to avoid having these hacks, I will look into it.

But this is not an issue, you can close it, thank you!

@afc163 afc163 closed this as completed Apr 4, 2019
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

2 participants