-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c2fc9f
commit 0bdbe52
Showing
23 changed files
with
812 additions
and
6,403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,120 +1,10 @@ | ||
require.extensions['.css'] = () => undefined; | ||
const path = require('path'); | ||
const glob = require('glob'); | ||
|
||
const mapper = { | ||
TextVariants: 'Text', | ||
ButtonVariant: 'Button', | ||
PaginationVariant: 'Pagination', | ||
SelectVariant: 'selectConstants', | ||
EmptyStateVariant: 'EmptyState', | ||
DropdownPosition: 'dropdownConstants', | ||
TextListVariants: 'TextList', | ||
TextListItemVariants: 'TextListItem', | ||
ClipboardCopyVariant: 'ClipboardCopy', | ||
TooltipPosition: 'Tooltip' | ||
}; | ||
|
||
const iconMapper = { | ||
AnsibeTowerIcon: 'ansibeTower-icon', | ||
ChartSpikeIcon: 'chartSpike-icon', | ||
CloudServerIcon: 'cloudServer-icon' | ||
}; | ||
|
||
const createPfReactTransform = (env) => [ | ||
'transform-imports', | ||
{ | ||
'@patternfly/react-core': { | ||
transform: (importName) => { | ||
let res; | ||
const pathname = path.resolve(__dirname, `node_modules/@patternfly/react-core/dist/${env}/**/${mapper[importName] || importName}.js`); | ||
const files = glob.sync(pathname); | ||
if (files.length > 0) { | ||
res = files[0]; | ||
} else { | ||
throw new Error(`File with importName ${importName} does not exist. Glob path: ${pathname}`); | ||
} | ||
|
||
res = res.split('/node_modules/').pop(); | ||
res = res.replace(/^\//, ''); | ||
return res; | ||
}, | ||
preventFullImport: false, | ||
skipDefaultConversion: true | ||
}, | ||
'@patternfly/react-icons': { | ||
transform: (importName) => | ||
`@patternfly/react-icons/dist/${env}/icons/${iconMapper[importName] || importName | ||
.split(/(?=[A-Z])/) | ||
.join('-') | ||
.toLowerCase()}`, | ||
preventFullImport: true | ||
}, | ||
'patternfly-react': { | ||
transform: (importName) => { | ||
let res; | ||
const files = glob.sync(path.resolve(__dirname, `../../node_modules/patternfly-react/dist/${env}/**/${importName}.js`)); | ||
if (files.length > 0) { | ||
res = files[0]; | ||
} else { | ||
throw new Error(`File with importName ${importName} does not exist`); | ||
} | ||
|
||
res = res.split('/node_modules/').pop(); | ||
res = res.replace(/^\//, ''); | ||
return res; | ||
}, | ||
preventFullImport: false, | ||
skipDefaultConversion: false | ||
} | ||
}, | ||
`pf-react-${env}` | ||
]; | ||
|
||
module.exports = { | ||
presets: [ | ||
[ | ||
'@babel/env', | ||
{ | ||
targets: '> 0.25%, not dead' | ||
} | ||
], | ||
'@babel/preset-react' | ||
], | ||
plugins: [ | ||
[ | ||
'@babel/plugin-proposal-decorators', | ||
{ | ||
legacy: true | ||
} | ||
], | ||
'@babel/plugin-transform-runtime', | ||
'@babel/plugin-syntax-dynamic-import', | ||
'@babel/plugin-proposal-object-rest-spread', | ||
'babel-plugin-lodash', | ||
'@babel/plugin-transform-react-display-name', | ||
'@babel/plugin-proposal-class-properties', | ||
'@babel/plugin-proposal-optional-chaining' | ||
], | ||
env: { | ||
cjs: { | ||
presets: [ [ '@babel/preset-env', { modules: 'commonjs' }] ], | ||
plugins: [ | ||
'./plugins/transform-scss-plugin', | ||
createPfReactTransform('js') | ||
] | ||
}, | ||
esm: { | ||
presets: [ [ '@babel/preset-env', { modules: false }] ], | ||
plugins: [ | ||
[ | ||
'./plugins/transform-scss-plugin', | ||
{ | ||
esm: true | ||
} | ||
], | ||
createPfReactTransform('esm') | ||
] | ||
} | ||
} | ||
}; | ||
presets: [ | ||
[ | ||
'@babel/env', | ||
{ | ||
targets: '> 0.25%, not dead' | ||
} | ||
] | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.