mirror of
https://github.com/HackPlan/polaris-react.git
synced 2026-01-12 22:44:36 +08:00
18 lines
695 B
JavaScript
18 lines
695 B
JavaScript
module.exports = function(api) {
|
|
// When building (using rollup) or running storybook (using babel-loader) we
|
|
// want to compile for the web otherwise compile for node usage (within jest)
|
|
const isWeb = api.caller((caller = {}) => {
|
|
return ['babel-loader', 'rollup-plugin-babel'].includes(caller.name);
|
|
});
|
|
|
|
const runtimePreset = isWeb
|
|
? ['babel-preset-shopify/web', {modules: false, typescript: true}]
|
|
: ['babel-preset-shopify/node', {modules: 'commonjs', typescript: true}];
|
|
|
|
// babel-preset-shopify/react only uses HMR if hot is true and the env is
|
|
// development or test
|
|
return {
|
|
presets: [runtimePreset, ['babel-preset-shopify/react', {hot: isWeb}]],
|
|
};
|
|
};
|