diff --git a/packages/react-scripts/config/jest/fileTransform.js b/packages/react-scripts/config/jest/fileTransform.js index aab67618c38..a3340858b0d 100644 --- a/packages/react-scripts/config/jest/fileTransform.js +++ b/packages/react-scripts/config/jest/fileTransform.js @@ -33,6 +33,8 @@ module.exports = { }; }), };`; + } else if (filename.match(/\.xml$/)) { + return `module.exports = { process: content => "module.exports = " + JSON.stringify(content) }`; } return `module.exports = ${assetFilename};`; diff --git a/packages/react-scripts/config/jest/xmlTransform.js b/packages/react-scripts/config/jest/xmlTransform.js new file mode 100644 index 00000000000..f7450b1bf8f --- /dev/null +++ b/packages/react-scripts/config/jest/xmlTransform.js @@ -0,0 +1,10 @@ +'use strict'; + +// This is a custom Jest transformer turning file imports into filenames. +// http://facebook.github.io/jest/docs/en/webpack.html + +module.exports = { + process(src, filename) { + return `module.exports = \`${src}\``; + }, +}; diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index bad4290061b..fdf9f6a0e02 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -40,6 +40,8 @@ const postcssNormalize = require('postcss-normalize'); const appPackageJson = require(paths.appPackageJson); +const tailwindcss = require('tailwindcss'); + // Source maps are resource heavy and can cause out of memory issue for large source files. const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false'; // Some apps do not need the benefits of saving a web request, so not inlining the chunk @@ -112,10 +114,14 @@ module.exports = function(webpackEnv) { ident: 'postcss', plugins: () => [ require('postcss-flexbugs-fixes'), + tailwindcss('./src/lib/config/tailwind.config.js'), require('postcss-preset-env')({ autoprefixer: { flexbox: 'no-2009', }, + features: { + 'nesting-rules': true, + }, stage: 3, }), // Adds PostCSS Normalize as the reset css with default options, @@ -412,7 +418,10 @@ module.exports = function(webpackEnv) { // @remove-on-eject-begin babelrc: false, configFile: false, - presets: [require.resolve('babel-preset-react-app')], + presets: [ + require.resolve('babel-preset-react-app'), + ['@babel/env', { targets: { node: 6 } }], + ], // Make sure we have a unique cache identifier, erring on the // side of caution. // We remove this when the user ejects because the default @@ -467,6 +476,7 @@ module.exports = function(webpackEnv) { require.resolve('babel-preset-react-app/dependencies'), { helpers: true }, ], + ['@babel/env', { targets: { node: 6 } }], ], cacheDirectory: true, // See #6846 for context on why cacheCompression is disabled @@ -557,6 +567,10 @@ module.exports = function(webpackEnv) { 'sass-loader' ), }, + { + test: [/\.xml$/], + loader: require.resolve('raw-loader'), + }, // "file" loader makes sure those assets get served by WebpackDevServer. // When you `import` an asset, you get its (virtual) filename. // In production, they would get copied to the `build` folder. diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 18c63e4b154..9759a12019c 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -66,6 +66,7 @@ "postcss-normalize": "8.0.1", "postcss-preset-env": "6.7.0", "postcss-safe-parser": "4.0.1", + "raw-loader": "^3.1.0", "react-app-polyfill": "^1.0.5", "react-dev-utils": "^10.0.0", "resolve": "1.13.1", diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index 5c17ad69a0e..b740fa65bf6 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -40,6 +40,7 @@ module.exports = (resolve, rootDir, isEjecting) => { ], testEnvironment: 'jest-environment-jsdom-fourteen', transform: { + '^.+\\.xml$': resolve('config/jest/xmlTransform.js'), '^.+\\.(js|jsx|ts|tsx)$': isEjecting ? '/node_modules/babel-jest' : resolve('config/jest/babelTransform.js'),