Skip to content

Commit 457cdc6

Browse files
committed
setup config override rules for emotion styles
1 parent fb0dd7c commit 457cdc6

File tree

7 files changed

+51
-11
lines changed

7 files changed

+51
-11
lines changed

.eslintrc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = {
1616
'@typescript-eslint/ban-ts-ignore': 'off',
1717
'@typescript-eslint/no-unused-vars': 'off',
1818
'@typescript-eslint/camelcase': 'off',
19-
'react/forbid-component-props': [1, { forbid: ['style'] }],
20-
'react/forbid-dom-props': [1, { forbid: ['style'] }],
19+
// 'react/forbid-component-props': [1, { forbid: ['style'] }],
20+
// 'react/forbid-dom-props': [1, { forbid: ['style'] }],
2121
},
2222
}

.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"editor.formatOnSave": true,
33
"editor.codeActionsOnSave": {
4-
"source.organizeImports": true,
4+
"source.organizeImports": false,
55
"source.fixAll": true
66
},
77
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],

web-app/.storybook/webpack.config.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ module.exports = ({ config }) => {
2222
},
2323
],
2424
],
25-
presets: [['react-app', { flow: false, typescript: true }], ['@emotion/babel-preset-css-prop']],
25+
presets: [
26+
// react-app
27+
['react-app', { flow: false, typescript: true }],
28+
// allow emotion css prop on html
29+
['@emotion/babel-preset-css-prop'],
30+
],
2631
},
2732
})
2833

web-app/config-overrides.js

+40-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,45 @@
1-
const { addLessLoader, addBabelPreset } = require('customize-cra')
1+
const path = require('path') // eslint-disable-line
22

33
module.exports = function override(config) {
4-
addBabelPreset('@emotion/babel-preset-css-prop')(config)
4+
config.module.rules.push({
5+
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
6+
use: [
7+
{
8+
loader: 'file-loader',
9+
options: {
10+
name: '[name].[ext]',
11+
outputPath: 'fonts/',
12+
},
13+
},
14+
],
15+
})
16+
17+
config.module.rules.push({
18+
test: /\.(ts|tsx)$/,
19+
loader: require.resolve('babel-loader'),
20+
options: {
21+
plugins: [
22+
// load css for @alifd/next components
23+
[
24+
'babel-plugin-import',
25+
{
26+
libraryName: '@alifd/next',
27+
style: true,
28+
},
29+
],
30+
],
31+
presets: [
32+
// react-app
33+
['react-app', { flow: false, typescript: true }],
34+
// allow emotion css prop on html
35+
['@emotion/babel-preset-css-prop'],
36+
],
37+
},
38+
})
39+
40+
config.resolve.extensions.push('.ts', '.tsx')
41+
42+
config.resolve.modules = ['node_modules', path.resolve(__dirname, './src')]
543

644
return config
745
}

web-app/src/components/Button/index.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Button as AlifdButton } from '@alifd/next'
22
import * as React from 'react'
3-
import { css, jsx } from '@emotion/core'
43

54
interface Props {
65
style?: React.CSSProperties
@@ -11,7 +10,7 @@ interface Props {
1110
}
1211

1312
const Button = (props: Props) => (
14-
<AlifdButton onClick={props.onClick} type={props.type} disabled={props.disabled} css={props.style}>
13+
<AlifdButton onClick={props.onClick} type={props.type} disabled={props.disabled} style={props.style}>
1514
{props.children}
1615
</AlifdButton>
1716
)

web-app/src/components/Icon/index.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Icon as AlifdIcon } from '@alifd/next'
22
import * as React from 'react'
3-
import { css, jsx } from '@emotion/core'
43

54
interface Props {
65
type: string
@@ -10,7 +9,7 @@ interface Props {
109
}
1110

1211
const Icon = (props: Props) => {
13-
return <AlifdIcon type={props.type} role={props.role} size={props.size} css={props.style} />
12+
return <AlifdIcon type={props.type} role={props.role} size={props.size} style={props.style} />
1413
}
1514

1615
export default Icon

web-app/src/styles/index.css

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@import '~@alifd/next/dist/next.css';
21
@import '~@alifd/theme-4/dist/next.css';
32

43
html {

0 commit comments

Comments
 (0)