Eject .babelrc instead of separate configs (#705)

Fixes #410, #674
This commit is contained in:
Dan Abramov
2016-09-23 00:33:14 +01:00
committed by GitHub
parent 5bf14f3d18
commit ba34b0b79b
10 changed files with 39 additions and 58 deletions

View File

@@ -12,7 +12,7 @@
const pathExists = require('path-exists');
const paths = require('../../config/paths');
module.exports = (resolve, rootDir) => {
module.exports = (resolve, rootDir, isEjecting) => {
const setupFiles = [resolve('config/polyfills.js')];
if (pathExists.sync(paths.testsSetup)) {
// Use this instead of `paths.testsSetup` to avoid putting
@@ -26,7 +26,6 @@ module.exports = (resolve, rootDir) => {
'^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': resolve('config/jest/FileStub.js'),
'^.+\\.css$': resolve('config/jest/CSSStub.js')
},
scriptPreprocessor: resolve('config/jest/transform.js'),
setupFiles: setupFiles,
testPathIgnorePatterns: ['<rootDir>/(build|docs|node_modules)/'],
testEnvironment: 'node',
@@ -35,5 +34,10 @@ module.exports = (resolve, rootDir) => {
if (rootDir) {
config.rootDir = rootDir;
}
if (!isEjecting) {
// This is unnecessary after ejecting because Jest
// will just use .babelrc in the project folder.
config.scriptPreprocessor = resolve('config/jest/transform.js');
}
return config;
};