Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
61 lines (45 sloc)
2.03 KB
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
| 'use strict'; | |
| var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray'); | |
| var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); | |
| var _extends2 = require('babel-runtime/helpers/extends'); | |
| var _extends3 = _interopRequireDefault(_extends2); | |
| var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray'); | |
| var _slicedToArray3 = _interopRequireDefault(_slicedToArray2); | |
| function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
| // Resolve styled-jsx plugins | |
| function styledJsxOptions(opts) { | |
| if (!opts) { | |
| return {}; | |
| } | |
| if (!Array.isArray(opts.plugins)) { | |
| return opts; | |
| } | |
| opts.plugins = opts.plugins.map(function (plugin) { | |
| if (Array.isArray(plugin)) { | |
| var _plugin = (0, _slicedToArray3.default)(plugin, 2), | |
| name = _plugin[0], | |
| options = _plugin[1]; | |
| return [require.resolve(name), options]; | |
| } | |
| return require.resolve(plugin); | |
| }); | |
| return opts; | |
| } | |
| var envPlugins = { | |
| 'development': [require.resolve('babel-plugin-transform-react-jsx-source')], | |
| 'production': [require.resolve('babel-plugin-transform-react-remove-prop-types')] | |
| }; | |
| var plugins = envPlugins[process.env.NODE_ENV] || envPlugins['development']; | |
| module.exports = function (context) { | |
| var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | |
| return { | |
| presets: [[require.resolve('babel-preset-env'), (0, _extends3.default)({ | |
| modules: false | |
| }, opts['preset-env'])], require.resolve('babel-preset-react')], | |
| plugins: [require.resolve('babel-plugin-react-require'), require.resolve('./plugins/handle-import'), require.resolve('babel-plugin-transform-object-rest-spread'), require.resolve('babel-plugin-transform-class-properties'), [require.resolve('babel-plugin-transform-runtime'), opts['transform-runtime'] || { | |
| helpers: false, | |
| polyfill: false, | |
| regenerator: true | |
| }], [require.resolve('styled-jsx/babel'), styledJsxOptions(opts['styled-jsx'])]].concat((0, _toConsumableArray3.default)(plugins)) | |
| }; | |
| }; |