mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-03-29 22:38:26 +08:00
* mv create-react-app/index.js -> create-react-app/creteReactApp.js * update to modern code style * var -> cosnt * set trailing-coma to es5 for prettier
50 lines
1.7 KiB
JavaScript
50 lines
1.7 KiB
JavaScript
// @remove-file-on-eject
|
|
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
'use strict';
|
|
|
|
const fs = require('fs');
|
|
const paths = require('../../config/paths');
|
|
|
|
module.exports = (resolve, rootDir, isEjecting) => {
|
|
// Use this instead of `paths.testsSetup` to avoid putting
|
|
// an absolute filename into configuration after ejecting.
|
|
const setupTestsFile = fs.existsSync(paths.testsSetup)
|
|
? '<rootDir>/src/setupTests.js'
|
|
: undefined;
|
|
|
|
// TODO: I don't know if it's safe or not to just use / as path separator
|
|
// in Jest configs. We need help from somebody with Windows to determine this.
|
|
const config = {
|
|
collectCoverageFrom: ['src/**/*.{js,jsx}'],
|
|
setupFiles: [resolve('config/polyfills.js')],
|
|
setupTestFrameworkScriptFile: setupTestsFile,
|
|
testPathIgnorePatterns: [
|
|
'<rootDir>[/\\\\](build|docs|node_modules|scripts)[/\\\\]',
|
|
],
|
|
testEnvironment: 'node',
|
|
testURL: 'http://localhost',
|
|
transform: {
|
|
'^.+\\.(js|jsx)$': isEjecting
|
|
? '<rootDir>/node_modules/babel-jest'
|
|
: resolve('config/jest/babelTransform.js'),
|
|
'^.+\\.css$': resolve('config/jest/cssTransform.js'),
|
|
'^(?!.*\\.(js|jsx|css|json)$)': resolve('config/jest/fileTransform.js'),
|
|
},
|
|
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],
|
|
moduleNameMapper: {
|
|
'^react-native$': 'react-native-web',
|
|
},
|
|
};
|
|
if (rootDir) {
|
|
config.rootDir = rootDir;
|
|
}
|
|
return config;
|
|
};
|