Files
polaris-react/babel.config.js
Ben Scott 55b05fa1ac Storybook: Make babel read ts files instead of using ts-loader
`useBuiltins: entry` is the default so no need to specify it.
2019-06-18 17:42:12 -07:00

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}]],
};
};