diff --git a/.travis.yml b/.travis.yml
index 860000b5c9b..803595b1532 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -26,3 +26,10 @@ matrix:
env: TEST_SUITE=old-node
- node_js: 6
env: TEST_SUITE=kitchensink
+notifications:
+ slack:
+ rooms:
+ secure: bhPLCxVEdmUTTaIwkmZMBBHtJVfSmdCS0feVgRdWLcAOhiSfAkwBhf42kZfovc1fwGxIeRukDERehzC8SqmRAX0U2o9aNuY+NyXWasWzFQlR2Dz2M5HPI0k1Qp8dMdPXQTr4GfQ+hsgpSzySnObjvdwchHNpDZDBsdEIUm6ppNvdYJA9E3BO8o7CNZyDiWNhJt47jx5u3Xh+g0iXix45wuMlLuZjnjXsSkFx39NPlLGsSCh4nTalJbpyB9Txh9zjBO4KCL0PoggFC8WGCoM9G73gn/oXie20nIX+NOMaAkGyN7aG0VxrVb5mAB4puhC+u2oPJRKc85REL2MRRcMLv8AC+/6nlXMjIF5WS2MhWKrejQlccO9lqqapsdDMENYx9+Oaxs4QDdQA1Hxd4J9eWBSwAO7xrhN2sTaUiOguEp+yX3EYWUtF1WtIU3NtxB6TTvOvbGHzJYcBJvU0zIywR4tik6HQuv6ZiC0+H50yfT9mm8KmVn0zdJ4O20QO7Fa+/WBpVMGHJLxLEP7Hj1I7cTOYE/B/5Dj8ABTUUoKV/q4hY24FcfQ3rLqFmbQxWdder95oiMh1TYtdP2c44m2E1BkmwUzjtJZCoxJOEKgjAaGdEA2+OxSuAIUmUhcJ6X0cSyll8OgyoOXiNQoHhrNMv/y9FxUvGdKDgX2uH96t8pE=
+ on_pull_requests: false
+ on_success: always
+ on_failure: change
\ No newline at end of file
diff --git a/README.md b/README.md
index b09630e90ba..6dbb6406b2d 100644
--- a/README.md
+++ b/README.md
@@ -1,224 +1,15 @@
-# Create React App [](https://travis-ci.org/facebookincubator/create-react-app)
+# `backpack-react-scripts` [](https://travis-ci.org/Skyscanner/backpack-react-scripts)
-Create React apps with no build configuration.
+**This is a fork of Facebook's [Create React App](https://github.com/facebook/create-react-app).**
-* [Creating an App](#creating-an-app) – How to create a new app.
-* [User Guide](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
+Files of interest:
+ - [README](packages/react-scripts/README.md)
+ - [CHANGELOG](packages/react-scripts/CHANGELOG.md)
-Create React App works on macOS, Windows, and Linux.
-If something doesn’t work, please [file an issue](https://github.com/facebookincubator/create-react-app/issues/new).
+Note that this repo also contains the following packages:
+ - [babel-preset-react-app](packages/babel-preset-react-app/)
+ - [create-react-app](packages/create-react-app/)
+ - [eslint-config-react-app](packages/eslint-config-react-app/)
+ - [react-dev-utils](packages/react-dev-utils/)
+ - [react-error-overlay](packages/react-error-overlay/)
-## Quick Overview
-
-```sh
-npx create-react-app my-app
-cd my-app
-npm start
-```
-
-*([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))*
-
-Then open [http://localhost:3000/](http://localhost:3000/) to see your app.
-When you’re ready to deploy to production, create a minified bundle with `npm run build`.
-
-
-
-
-
-### Get Started Immediately
-
-You **don’t** need to install or configure tools like Webpack or Babel.
-They are preconfigured and hidden so that you can focus on the code.
-
-Just create a project, and you’re good to go.
-
-## Creating an App
-
-**You’ll need to have Node >= 6 on your local development machine** (but it’s not required on the server). You can use [nvm](https://github.com/creationix/nvm#installation) (macOS/Linux) or [nvm-windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows) to easily switch Node versions between different projects.
-
-To create a new app, run a single command:
-
-```sh
-npx create-react-app my-app
-```
-
-*([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))*
-
-It will create a directory called `my-app` inside the current folder.
-Inside that directory, it will generate the initial project structure and install the transitive dependencies:
-
-```
-my-app
-├── README.md
-├── node_modules
-├── package.json
-├── .gitignore
-├── public
-│ └── favicon.ico
-│ └── index.html
-│ └── manifest.json
-└── src
- └── App.css
- └── App.js
- └── App.test.js
- └── index.css
- └── index.js
- └── logo.svg
- └── registerServiceWorker.js
-```
-
-No configuration or complicated folder structures, just the files you need to build your app.
-Once the installation is done, you can open your project folder:
-
-```sh
-cd my-app
-```
-
-Inside the newly created project, you can run some built-in commands:
-
-### `npm start` or `yarn start`
-
-Runs the app in development mode.
-Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
-
-The page will automatically reload if you make changes to the code.
-You will see the build errors and lint warnings in the console.
-
-
-
-### `npm test` or `yarn test`
-
-Runs the test watcher in an interactive mode.
-By default, runs tests related to files changed since the last commit.
-
-[Read more about testing.](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#running-tests)
-
-### `npm run build` or `yarn build`
-
-Builds the app for production to the `build` folder.
-It correctly bundles React in production mode and optimizes the build for the best performance.
-
-The build is minified and the filenames include the hashes.
-By default, it also [includes a service worker](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app) so that your app loads from local cache on future visits.
-
-Your app is ready to be deployed.
-
-## User Guide
-
-The [User Guide](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md) includes information on different topics, such as:
-
-- [Updating to New Releases](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#updating-to-new-releases)
-- [Folder Structure](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#folder-structure)
-- [Available Scripts](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#available-scripts)
-- [Supported Browsers](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#supported-browsers)
-- [Supported Language Features and Polyfills](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#supported-language-features-and-polyfills)
-- [Syntax Highlighting in the Editor](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#syntax-highlighting-in-the-editor)
-- [Displaying Lint Output in the Editor](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#displaying-lint-output-in-the-editor)
-- [Formatting Code Automatically](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#formatting-code-automatically)
-- [Debugging in the Editor](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#debugging-in-the-editor)
-- [Changing the Page ``](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#changing-the-page-title)
-- [Installing a Dependency](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#installing-a-dependency)
-- [Importing a Component](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#importing-a-component)
-- [Code Splitting](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting)
-- [Adding a Stylesheet](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-a-stylesheet)
-- [Post-Processing CSS](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#post-processing-css)
-- [Adding a CSS Preprocessor (Sass, Less etc.)](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-a-css-preprocessor-sass-less-etc)
-- [Adding Images, Fonts, and Files](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-images-fonts-and-files)
-- [Using the `public` Folder](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#using-the-public-folder)
-- [Using Global Variables](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#using-global-variables)
-- [Adding Bootstrap](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-bootstrap)
-- [Adding Flow](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-flow)
-- [Adding a Router](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-a-router)
-- [Adding Custom Environment Variables](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-custom-environment-variables)
-- [Can I Use Decorators?](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#can-i-use-decorators)
-- [Fetching Data with AJAX Requests](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#fetching-data-with-ajax-requests)
-- [Integrating with an API Backend](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#integrating-with-an-api-backend)
-- [Proxying API Requests in Development](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#proxying-api-requests-in-development)
-- [Using HTTPS in Development](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#using-https-in-development)
-- [Generating Dynamic `` Tags on the Server](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#generating-dynamic-meta-tags-on-the-server)
-- [Pre-Rendering into Static HTML Files](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#pre-rendering-into-static-html-files)
-- [Running Tests](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#running-tests)
-- [Debugging Tests](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#debugging-tests)
-- [Developing Components in Isolation](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#developing-components-in-isolation)
-- [Publishing Components to npm](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#publishing-components-to-npm)
-- [Making a Progressive Web App](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app)
-- [Analyzing the Bundle Size](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#analyzing-the-bundle-size)
-- [Deployment](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment)
-- [Advanced Configuration](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#advanced-configuration)
-- [Troubleshooting](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#troubleshooting)
-
-A copy of the user guide will be created as `README.md` in your project folder.
-
-## How to Update to New Versions?
-
-Please refer to the [User Guide](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#updating-to-new-releases) for this and other information.
-
-## Philosophy
-
-* **One Dependency:** There is just one build dependency. It uses Webpack, Babel, ESLint, and other amazing projects, but provides a cohesive curated experience on top of them.
-
-* **No Configuration Required:** You don't need to configure anything. Reasonably good configuration of both development and production builds is handled for you so you can focus on writing code.
-
-* **No Lock-In:** You can “eject” to a custom setup at any time. Run a single command, and all the configuration and build dependencies will be moved directly into your project, so you can pick up right where you left off.
-
-## What’s Included?
-
-Your environment will have everything you need to build a modern single-page React app:
-
-* React, JSX, ES6, and Flow syntax support.
-* Language extras beyond ES6 like the object spread operator.
-* Autoprefixed CSS, so you don’t need `-webkit` or other prefixes.
-* A fast interactive unit test runner with built-in support for coverage reporting.
-* A live development server that warns about common mistakes.
-* A build script to bundle JS, CSS, and images for production, with hashes and sourcemaps.
-* An offline-first [service worker](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers) and a [web app manifest](https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/), meeting all the [Progressive Web App](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app) criteria.
-* Hassle-free updates for the above tools with a single dependency.
-
-Check out [this guide](https://github.com/nitishdayal/cra_closer_look) for an overview of how these tools fit together.
-
-The tradeoff is that **these tools are preconfigured to work in a specific way**. If your project needs more customization, you can ["eject"](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-eject) and customize it, but then you will need to maintain this configuration.
-
-## Popular Alternatives
-
-Create React App is a great fit for:
-
-* **Learning React** in a comfortable and feature-rich development environment.
-* **Starting new single-page React applications.**
-* **Creating examples** with React for your libraries and components.
-
-Here’s a few common cases where you might want to try something else:
-
-* If you want to **try React** without hundreds of transitive build tool dependencies, consider [using a single HTML file or an online sandbox instead](https://reactjs.org/docs/try-react.html).
-
-* If you need to **integrate React code with a server-side template framework** like Rails or Django, or if you’re **not building a single-page app**, consider using [nwb](https://github.com/insin/nwb) or [Neutrino](https://neutrino.js.org/) which are more flexible.
-
-* If you need to **publish a React component**, [nwb](https://github.com/insin/nwb) can [also do this](https://github.com/insin/nwb#react-components-and-libraries), as well as [Neutrino's react-components preset](https://neutrino.js.org/packages/react-components/).
-
-* If you want to do **server rendering** with React and Node.js, check out [Next.js](https://github.com/zeit/next.js/) or [Razzle](https://github.com/jaredpalmer/razzle). Create React App is agnostic of the backend, and just produces static HTML/JS/CSS bundles.
-
-* If your website is **mostly static** (for example, a portfolio or a blog), consider using [Gatsby](https://www.gatsbyjs.org/) instead. Unlike Create React App, it pre-renders the website into HTML at the build time.
-
-* If you want to use **TypeScript**, consider using [create-react-app-typescript](https://github.com/wmonk/create-react-app-typescript).
-
-* Finally, if you need **more customization**, check out [Neutrino](https://neutrino.js.org/) and its [React preset](https://neutrino.js.org/packages/react/).
-
-All of the above tools can work with little to no configuration.
-
-If you prefer configuring the build yourself, [follow this guide](https://reactjs.org/docs/add-react-to-an-existing-app.html).
-
-## Contributing
-
-We'd love to have your helping hand on `create-react-app`! See [CONTRIBUTING.md](CONTRIBUTING.md) for more information on what we're looking for and how to get started.
-
-## React Native
-
-Looking for something similar, but for React Native?
-Check out [Create React Native App](https://github.com/react-community/create-react-native-app/).
-
-## Acknowledgements
-
-We are grateful to the authors of existing related projects for their ideas and collaboration:
-
-* [@eanplatter](https://github.com/eanplatter)
-* [@insin](https://github.com/insin)
-* [@mxstbr](https://github.com/mxstbr)
diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json
index 81dd0fa1fe9..8b17dded486 100644
--- a/packages/babel-preset-react-app/package.json
+++ b/packages/babel-preset-react-app/package.json
@@ -1,4 +1,5 @@
{
+ "private": true,
"name": "babel-preset-react-app",
"version": "3.1.2",
"description": "Babel preset used by Create React App",
diff --git a/packages/create-react-app/package.json b/packages/create-react-app/package.json
index 4d8f4112ead..2539bbc289b 100644
--- a/packages/create-react-app/package.json
+++ b/packages/create-react-app/package.json
@@ -1,4 +1,5 @@
{
+ "private": true,
"name": "create-react-app",
"version": "1.5.2",
"keywords": [
diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json
index c13b0417c46..c28192a83ef 100644
--- a/packages/eslint-config-react-app/package.json
+++ b/packages/eslint-config-react-app/package.json
@@ -1,4 +1,5 @@
{
+ "private": true,
"name": "eslint-config-react-app",
"version": "2.1.0",
"description": "ESLint configuration used by Create React App",
diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js
index 4add9f9c1bc..d462f9c1db0 100644
--- a/packages/react-dev-utils/WebpackDevServerUtils.js
+++ b/packages/react-dev-utils/WebpackDevServerUtils.js
@@ -25,6 +25,11 @@ let handleCompile;
// We only use this block for testing of Create React App itself:
const isSmokeTest = process.argv.some(arg => arg.indexOf('--smoke-test') > -1);
if (isSmokeTest) {
+ // process.env.UV_THREADPOOL_SIZE default value is 4. Setting it to 20 seems to stop the build hanging.
+ // We only do this if the --smoke-test flag is passed because we haven't seen this in the wild yet.
+ // See https://github.com/sass/node-sass/issues/857 & https://github.com/jtangelder/sass-loader/issues/147.
+ process.env.UV_THREADPOOL_SIZE = 50;
+
handleCompile = (err, stats) => {
if (err || stats.hasErrors() || stats.hasWarnings()) {
process.exit(1);
diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json
index 690c275f4d6..c0235f3c832 100644
--- a/packages/react-dev-utils/package.json
+++ b/packages/react-dev-utils/package.json
@@ -1,4 +1,5 @@
{
+ "private": true,
"name": "react-dev-utils",
"version": "5.0.2",
"description": "Webpack utilities used by Create React App",
diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json
index 06354daf1b6..ab7e80e8233 100644
--- a/packages/react-error-overlay/package.json
+++ b/packages/react-error-overlay/package.json
@@ -1,4 +1,5 @@
{
+ "private": true,
"name": "react-error-overlay",
"version": "4.0.1",
"description": "An overlay for displaying stack frames.",
diff --git a/packages/react-scripts/CHANGELOG.md b/packages/react-scripts/CHANGELOG.md
new file mode 100644
index 00000000000..acfc2399cee
--- /dev/null
+++ b/packages/react-scripts/CHANGELOG.md
@@ -0,0 +1,354 @@
+# `backpack-react-scripts` Change Log
+
+## 6.0.1 - 2018-02-11
+### Breaking
+- Add css modules to `.css` imports. This is only valid for projects using css modules
+
+## 5.2.1 - 2018-09-10
+### Fixed
+- Remove peer dependency warnings
+- Remove usage of `bpk-component-grid`
+
+## 5.2.0 - 2018-09-06
+### Added
+- Rebased onto `upstream/master` v1.1.5 (dc74990b89b5c6e143b522c759be3dac2c286514)
+- Upgraded dependencies, mostly `eslint` based.
+
+## 5.1.1 - 2018-04-11
+### Fixed
+- `backpack-react-scripts` listed inside of `devDependencies` instead of `dependencies`
+- `registerServiceWorker.js` no longer appears in project output
+
+## 5.1.0 - 2018-04-10
+### Added
+- Rebased onto `upstream/master` v1.1.4 (dfbc71ce2ae07547a8544cce14a1a23fac99e071)
+
+## 5.0.10 - 2018-03-21
+### Fixed
+- New `disablePolyfills` config in `package.json`. You can opt out of including polyfills from the output bundle like so:
+
+```json
+ "backpack-react-scripts": {
+ "disablePolyfills": true
+ }
+```
+
+## 5.0.9 - 2018-03-14
+### Fixed
+- New `crossOriginLoading` config in `package.json`. You can configure cross-origin loading of dynamic chunks:
+
+```json
+ "backpack-react-scripts": {
+ "crossOriginLoading": "anonymous"
+ }
+```
+
+## 5.0.8 - 2018-03-07
+### Fixed
+- New `amdExcludes` config in `package.json`. You can now disable AMD parsing for specific modules like so:
+
+```json
+ "backpack-react-scripts": {
+ "amdExcludes": [
+ "globalize"
+ ]
+ }
+```
+
+## 5.0.7 - 2018-03-06
+### Fixed
+- Use `package.json` name field as value for `output.jsonpFunction`, this is important for when multiple webpack runtimes from different compilation are used on the same page
+
+## 5.0.6 - 2018-01-31
+### Fixed
+- CSS Modules hashing now uses `package.json` name field as a salt
+
+## 5.0.5 - 2018-01-15
+### Fixed
+- Added `saddlebag-` prefix to the jest config
+
+## 5.0.4 - 2018-01-11
+### Added
+- Added `saddlebag-` prefix for saddlebag modules
+
+## 5.0.3 - 2017-12-21
+### Fixed
+- Rebased onto `upstream/master` v1.0.17 (4b55193f0ad479f26b0f5e153bb4b152a1ee03e7)
+- Peer dependency issues with `postcss-less` & `sugarss`
+
+## 5.0.2 - 2017-11-03
+### Fixed
+- Scope the disabling of AMD for `lodash` only
+
+## 5.0.1 - 2017-11-02
+### Fixed
+- Prevent lodash imports from leaking on to the global scope, see https://github.com/webpack/webpack/issues/3017#issuecomment-285954512
+- Upgraded `stylelint` to `^8.2.0` and `stylelint-config-skyscanner` to `^1.0.1`
+
+## 5.0.0 - 2017-10-30
+### Breaking
+- Upgraded [`eslint-config-skyscanner`](https://github.com/Skyscanner/eslint-config-skyscanner/blob/master/changelog.md#300---upgraded-esling-config-airbnb-peer-dependencies) to `3.0.0`.
+
+## 4.0.8 - 2017-10-12
+### Fixed
+- Rebased onto `upstream/master` (b2c0b3f74b47f0f85e3f17f7d3249b7e536cda05)
+- Locked `react` & `react-dom` versions to `^15.0.0` for now
+
+## 4.0.7 - 2017-08-24
+### Fixed
+- Fixed issue with classnames not being hashed correctly for projects using CSS Modules
+
+## 4.0.6 - 2017-08-22
+### Fixed
+- Upgraded sass-loader to 6.0.6 which fixes peer dependency warning with webpack (caused shrinkwraps to fail)
+- Upgraded bpk-mixins to 16.3.1
+
+## 4.0.5 - 2017-08-17
+### Fixed
+- Rebased onto `upstream/master` (e8a3e4b2995f4c6e49c0a7ed653a1646a7b5e515)
+
+## 4.0.3 - 2017-08-10
+### Fixed
+- Production and SSR builds will now use `optimize-css-assets-webpack-plugin` with `cssnano` to optimize output CSS. This gets rid of duplication of global CSS constructs such as keyframes.
+
+## 4.0.2 - 2017-07-28
+### Fixed
+- Deprecated BpkHeading and BpkParagraph
+- Added BpkText component
+- Updated all other Backpack dependencies to latest versions
+
+## 4.0.1 - 2017-07-27
+### Fixed
+- Updated eslint-plugin-import to 2.7.0 to fix `npm shrinkwrap --save-dev`
+
+## 4.0.0 - 2017-07-27
+### Changed
+- Updated stylelint to 8.0.0 and stylelint-config-skyscanner to 1.0.0
+
+## 3.0.1 - 2017-07-12
+### Fixed
+- Mocked CSS Modules for Jest, so snapshot tests include the original class names
+
+## 3.0.0 - 2017-07-11
+### Changed
+- Enabled [CSS Modules](https://github.com/css-modules/css-modules) by default
+ - You can use the config option `cssModules` to opt out:
+ ```
+ "backpack-react-scripts": {
+ "cssModules": false
+ }
+ ```
+ In this case, Sass files will not be treated as CSS Modules by default. However, you can opt-in on a
+ per-file basis using the naming convention: `*.module.scss`.
+ - Backpack components will _always_ be treated as CSS Modules, even if you opt out
+ - All Backpack components need to be on these versions (or higher) to work:
+ - bpk-component-accordion@1.1.0
+ - bpk-component-autosuggest@3.0.13
+ - bpk-component-badge@0.1.0
+ - bpk-component-banner-alert@1.1.0
+ - bpk-component-barchart@0.1.0
+ - bpk-component-blockquote@0.1.0
+ - bpk-component-breakpoint@0.1.22
+ - bpk-component-button@1.6.33
+ - bpk-component-calendar@3.3.0
+ - bpk-component-card@0.1.0
+ - bpk-component-checkbox@1.2.0
+ - bpk-component-close-button@0.1.0
+ - bpk-component-code@0.1.0
+ - bpk-component-content-container@1.1.0
+ - bpk-component-datepicker@6.1.1
+ - bpk-component-fieldset@0.3.1
+ - bpk-component-form-validation@0.1.0
+ - bpk-component-grid-toggle@0.1.0
+ - bpk-component-grid@1.1.0
+ - bpk-component-heading@2.1.0
+ - bpk-component-horizontal-nav@0.1.0
+ - bpk-component-icon@3.7.0
+ - bpk-component-input@3.2.1
+ - bpk-component-label@3.2.0
+ - bpk-component-link@0.6.0
+ - bpk-component-list@0.1.0
+ - bpk-component-loading-button@0.1.0
+ - bpk-component-modal@1.1.0
+ - bpk-component-nudger@0.1.0
+ - bpk-component-panel@0.1.0
+ - bpk-component-paragraph@0.3.0
+ - bpk-component-popover@1.1.0
+ - bpk-component-progress@0.1.0
+ - bpk-component-radio@1.1.0
+ - bpk-component-router-link@0.2.0
+ - bpk-component-rtl-toggle@0.0.73
+ - bpk-component-select@2.1.0
+ - bpk-component-spinner@2.1.0
+ - bpk-component-star-rating@0.0.3
+ - bpk-component-table@0.1.0
+ - bpk-component-textarea@0.1.0
+ - bpk-component-ticket@0.1.0
+ - bpk-component-tooltip@1.1.0
+ - bpk-react-utils@2.0.0
+
+## 2.0.3 - 2017-07-010
+### Fixed
+- Rebased onto `upstream/master` (f495c15578403cf2dbac211493ae8fb6ac742415)
+
+## 2.0.1 - 2017-07-04
+### Changed
+- Replaced the "babelIncludeRegex" config option in `package.json` with "babelIncludePrefixes". You can now
+ enable transpilation for your dependencies by adding package prefixes like so:
+ ```
+ {
+ ...
+ "backpack-react-scripts": {
+ "babelIncludePrefixes": [
+ "my-module-prefix-",
+ "some-dependency"
+ ]
+ }
+ }
+ ```
+
+### Changed
+- Upgraded `eslint-config-skyscanner` to `2.0.0` which uses the `babel-eslint` parse
+
+## 1.0.1 - 2017-06-12
+### Added
+- Added `babel-eslint` as dependency so it can be used with ESLint when dynamic `import()` statements are used
+
+### Changed
+- Upgraded `eslint-config-skyscanner` to `2.0.0` which uses the `babel-eslint` parse
+
+## 1.0.0 - 2017-05-29
+### Changed
+- Rebased from `upstream/master` (fbaeff2d6ef83ae5dc8213150e0fa6589ed29150)
+- TLDR; this upgrades the upstream dependency `react-scripts` to `^1.0.0` - please read the [blog post](https://facebook.github.io/react/blog/2017/05/18/whats-new-in-create-react-app.html) for a summary of the new features this brings
+- This is a major release, meaning there are a few breaking changes (summarised below). Please refer to the [`react-scripts` changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md#100-may-18-2017) for detailed migration documentations.
+ - [Ensure application and test files reside in src/](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md#ensure-application-and-test-files-reside-in-src)
+ - [You can no longer import file content](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md#you-can-no-longer-import-file-content)
+ - [Confusing window globals can no longer be used without window qualifier](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md#confusing-window-globals-can-no-longer-be-used-without-window-qualifier)
+ - [Jest snapshot format has changed](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md#how-do-i-make-my-tests-work-with-jest-20)
+
+## 0.0.19 - 2017-05-02
+### Added
+- The ability to configure "babelIncludeRegex" in package json
+
+## 0.0.18 - 2017-04-10
+### Added
+- Support for new `bpk-icon` mixin from `bpk-mixins`
+
+## 0.0.17 - 2017-04-06
+### Fixed
+- Rebased from `upstream/0.9.x` (ebebe80383eb15b4759a0cd5ea12015eaac94c0e)
+- Now moves `react` and `react-dom` from dependencies to devDependencies
+
+## 0.0.16 - 2017-03-30
+### Added
+- Upgrading `eslint-config-skyscanner` to v1.1.0
+- Upgrading `stylelint-config-skyscanner` to v0.1.3
+- Upgrading `eslint-plugin-react` to v6.10.3 as [undelying issue](https://github.com/yannickcr/eslint-plugin-react/issues/1117) which caused it to be pinned was resolved
+- Upgrading `node-sass` to v4.5.0 to make it compatible with latest version of `bpk-mixins`
+- Upgrading all Backpack dev dependencies:
+ - `bpk-component-button` to v1.6.6
+ - `bpk-component-code` to v0.0.58
+ - `bpk-component-grid` to v1.0.8
+ - `bpk-component-heading` to v1.2.7
+ - `bpk-component-paragraph` to v0.2.1
+ - `bpk-mixins` to v11.0.2
+ - `bpk-stylesheets` to v3.2.16
+- Upgrading `detect-port` to v1.1.1
+
+## 0.0.15 - 2017-03-27
+### Added
+- The ability to lint SCSS with `stylelint-config-skyscanner`
+ - run `npm run lint:scss` or just `npm run lint` for both JS and SCSS linting
+- The ability to automatically fix many SCSS linting issues using `stylefmt`
+ - run `npm run lint:scss:fix`
+- The ability to automatically fix many JS linting issues using `eslint --fix`
+ - run `npm run lint:js:fix`
+
+## 0.0.14 - 2017-03-20
+### Added
+- Upgrading `eslint-config-skyscanner` to v1.0.0
+
+### Fixed
+- Pinning `eslint-plugin-react` to 6.10.0 to fix indent bug
+
+## 0.0.13 - 2017-03-09
+### Added
+- The ability to configure "ssrExternals" in package json
+
+## 0.0.12 - 2017-03-01
+### Fixed
+- The backpack module regex now works on windows
+
+## 0.0.11 - 2017-02-27
+### Changed
+- Removed backpack logo usage from output template
+
+### Added
+- There is now an `.editorconfig` in the output template
+
+## 0.0.10 - 2017-01-05
+### Changed
+- Rebased from `upstream/master` (4d7b7544e74db1aaca22e847b233ed1f3b95b72b)
+ - Updates `babel-jest` && `jest` packages to 18.0.0
+- Upgraded `eslint` & `eslint-plugin-react` to 3.12.2 & 6.8.0 respectively
+
+### Added
+- Added ability to configure "externals" in package json
+
+## 0.0.9 - 2016-12-20
+### Added
+- Server Side Rendering support (proof of concept):
+ - `webpack.config.ssr.js`: This is a duplicate of `webpack.config.prod.js` modified to target a server side node environment
+ - `build.js` now checks if an `ssr.js` file exists at the app root, if so it will compile it in parallel with the optimized browser bundle leaving an
+ `ssr.js` file in the build directory ready to be required on the server
+ - See the [readme](https://github.com/Skyscanner/backpack-react-scripts/tree/master/packages/react-scripts/template#server-side-rendering-ssr) for detailed instructions.
+
+## 0.0.8
+### Changed
+- Rebased from `upstream/master` (94c912dc60561c931232caf9cf5442082711227c)
+ - Mostly bug fixes and dependency upgrades, see [create-react-app's changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md)
+ (between versions `v0.8.0` -> `v0.8.4`)
+
+## 0.0.7
+### Fixed
+- Added base stylesheet scripts to the template so that hover effects work
+
+## 0.0.6
+### Changed
+- Removed eslint from webpack to a separate `npm run lint` task
+- Swapped out `eslint-config-react-app` in favour of `eslint-config-skyscanner`
+
+### Added
+- A `backpack-react-scripts` specific readme
+
+## 0.0.5
+### Fixed
+- Rebased from `upstream/master` (bcc469c9a5c7916ec10786f133769cdda2c80188)
+ - Most notable change is Yarn support
+
+## 0.0.4
+### Fixed
+- Reverted nested components dir
+
+## 0.0.3
+### Added
+- New Backpack template
+ - Backpack stylesheet and Sass mixin integration
+ - Backpack button, code, grid, heading & paragraph components integration
+ - `.eslintrc` for editor integration
+ - Nested components into `src/components/` dir
+
+## 0.0.2
+### Fixed
+- Removed `bundledDependencies`
+
+## 0.0.1
+### Changed
+- Customised `react-scripts` package to be `backpack-react-scripts`
+- Marked all other packages as private
+
+### Added
+- Sass stylesheet support
+- Babel will now compile imports from the `node_modules` folder that match `/bpk-*`
+- Drone build configuration
diff --git a/packages/react-scripts/README.md b/packages/react-scripts/README.md
index 8004b887004..7efe5f91f98 100644
--- a/packages/react-scripts/README.md
+++ b/packages/react-scripts/README.md
@@ -1,7 +1,137 @@
-# react-scripts
+# backpack-react-scripts
-This package includes scripts and configuration used by [Create React App](https://github.com/facebookincubator/create-react-app).
-Please refer to its documentation:
+This package is a fork of [Create React App](https://github.com/facebookincubator/create-react-app) (specifically the
+`react-scripts` package). It's intended to be used in conjuction with `create-react-app` like so:
-* [Getting Started](https://github.com/facebookincubator/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
-* [User Guide](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
+```sh
+# we still rely on facebooks global `create-react-app` cli
+npm install -g create-react-app
+
+# specify `backpack-react-scripts` as the scripts package to use
+create-react-app my-app --scripts-version=backpack-react-scripts
+
+# start your app development like you normally would with `create-react-app`
+cd my-app
+npm start
+```
+
+## Why fork?
+
+Out of the box, `create-react-app` doesn't work well with Backpack components because it has no support for
+Sass stylesheets or uncompiled dependencies in the `node_modules` folder. We also want to be able to tailor
+the template to use Backpack out-the-box.
+
+## What is different in our fork?
+
+This is a high-level overview of the changed we made to this fork.
+
+### Moved ESLint from Webpack to npm script
+
+> See `config/webpack.config.{dev,prod}.js`, `package.json`, `scripts/{eject,init}.js`, `template/.eslintrc`
+
+By default, react-scripts runs all code through ESLint *on build*. As our [ESLint configuration](https://github.com/Skyscanner/eslint-config-skyscanner) is quite opinionated, we have disabled this functionality.
+
+We have added an npm script so you can still run the linter at will using `npm run lint`.
+
+### Added stylelint configuration
+
+> See `package.json`, `template/.stylelintrc.json`
+
+We added Skyscanner's [Stylelint configuration](https://github.com/Skyscanner/stylelint-config-skyscanner/).
+
+### Added in Backpack components
+
+> See `scripts/init.js`, `template/src/*`
+
+We pre-install some Backpack components to help you get started quickly.
+
+### Added a server-side rendering (SSR) Webpack configuration
+
+> See `config/webpack.config.ssr.js`
+
+This Webpack configuration is used to to enable easy server-side rendering. It is derived from `config/webpack.config.prod.js`.
+
+Everything that we don't need from the prod config is not removed, but *commented out*.
+
+### Moved React and ReactDOM from `dependencies` to `devDependencies`
+
+> See `scripts/init.js`
+
+Any app built with backpack-react-scripts should always output a bundle, and therefore it is enough to keep React and ReactDOM in `devDependencies`. In many cases, they should also be external dependencies (not part of the bundle).
+
+As the CRA CLI install React and ReactDOM, we cannot really do anything about that; but we can move the entries in `package.json` from `dependencies` to `devDependencies`.
+
+### Enabled CSS Modules
+
+> See `config/webpack.config.{dev,prod,ssr}.js`
+
+All Sass files are by default treated as [CSS Modules](https://github.com/css-modules/css-modules). You can opt out of this behaviour using the following config option:
+
+```
+"backpack-react-scripts": {
+ "cssModules": false
+}
+```
+
+If you decide to opt out, Sass files will not be treated as CSS Modules by default. However, you can opt-in on a per-file basis using the naming convention: `*.module.scss`.
+
+> Backpack components will _always_ be treated as CSS Modules, even if you opt out
+
+## Releasing a new version of `backpack-react-scripts`
+
+1. To publish a new version of `backpack-react-scripts`, run the following command:
+
+ ```
+ npm run publish -- --scope backpack-react-scripts
+ ```
+
+1. You will be prompted to select a new semver version (MAJOR, MINOR, PATCH). Use the [CHANGELOG.md](./CHANGELOG.md) to decide on the nature of the changes since the last release.
+ * If you want to be extra careful, you can publish a prerelease by running this instead:
+
+ ```
+ npm run publish -- --scope backpack-react-scripts --canary
+ ```
+
+1. Update the [CHANGELOG.md](./CHANGELOG.md) with the new version, taking care to follow the format of previous releases.
+
+## Keeping this fork updated
+
+We wish to keep this fork updated with the upstream repo to benefit from the ongoing open source development
+of `create-react-app`. To keep this fork up to date, please follow the steps below:
+
+1. Ensure `master` is in sync with `upstream/master`:
+
+ ```sh
+ git checkout master
+ git remote add upstream git@github.com:facebook/create-react-app.git
+ git fetch upstream
+ git reset --hard upstream/master
+ git push --force-with-lease
+ ```
+
+1. Rebase `fork` on top of a **tagged release** on `master`:
+
+ ```sh
+ git checkout fork
+ git rebase
+ ```
+
+ > **Note:** `` should be the SHA-1 of the latest upstream release - _not_ just the latest i.e. `upstream/master`
+
+1. Pair with someone else to fix any conflicts and cross examine changes in upstream with changes in our fork.
+
+ > This is the most time consuming part. Take care to make sure you are not regressing any functionality that we have added in our fork.
+
+1. Re-name your local, rebased `fork` branch to something else and push it to origin. This will ensure it runs through CI and you can verify your changes.
+
+ ```sh
+ git branch -m
+ git push origin
+ ```
+
+1. Finally, when we are confident that the rebase has been successful, re-name your branch back to `fork` and push it to origin:
+
+ ```sh
+ git branch -m fork
+ git push --force-with-lease
+ ```
diff --git a/packages/react-scripts/config/getLocalIdent.js b/packages/react-scripts/config/getLocalIdent.js
new file mode 100644
index 00000000000..a6b1a7aeca1
--- /dev/null
+++ b/packages/react-scripts/config/getLocalIdent.js
@@ -0,0 +1,21 @@
+'use strict';
+
+const getLocalIdent = require('css-loader/lib/getLocalIdent');
+
+const paths = require('./paths');
+const pkgJson = require(paths.appPackageJson);
+
+module.exports = (context, localIdentName, localName, options) => {
+ const customOptions = {};
+
+ if (pkgJson.name) {
+ customOptions.hashPrefix = pkgJson.name;
+ }
+
+ return getLocalIdent(
+ context,
+ localIdentName,
+ localName,
+ Object.assign(options, customOptions)
+ );
+};
diff --git a/packages/react-scripts/config/paths.js b/packages/react-scripts/config/paths.js
index 718b898bb8d..8a6104cf083 100644
--- a/packages/react-scripts/config/paths.js
+++ b/packages/react-scripts/config/paths.js
@@ -46,6 +46,10 @@ function getServedPath(appPackageJson) {
return ensureSlash(servedUrl, true);
}
+// Regex to match backpack node modules
+const backpackModulesRegex = /node_modules[\\/]bpk-/;
+const saddlebagModulesRegex = /node_modules[\\/]saddlebag-/;
+
// config after eject: we're in ./config/
module.exports = {
dotenv: resolveApp('.env'),
@@ -60,6 +64,9 @@ module.exports = {
appNodeModules: resolveApp('node_modules'),
publicUrl: getPublicUrl(resolveApp('package.json')),
servedPath: getServedPath(resolveApp('package.json')),
+ backpackModulesRegex: backpackModulesRegex,
+ saddlebagModulesRegex: saddlebagModulesRegex,
+ appSsrJs: resolveApp('src/ssr.js'),
};
// @remove-on-eject-begin
@@ -83,6 +90,9 @@ module.exports = {
// These properties only exist before ejecting:
ownPath: resolveOwn('.'),
ownNodeModules: resolveOwn('node_modules'), // This is empty on npm 3
+ backpackModulesRegex: backpackModulesRegex,
+ saddlebagModulesRegex: saddlebagModulesRegex,
+ appSsrJs: resolveApp('src/ssr.js'),
};
const ownPackageJson = require('../package.json');
@@ -113,6 +123,9 @@ if (
// These properties only exist before ejecting:
ownPath: resolveOwn('.'),
ownNodeModules: resolveOwn('node_modules'),
+ backpackModulesRegex: backpackModulesRegex,
+ saddlebagModulesRegex: saddlebagModulesRegex,
+ appSsrJs: resolveOwn('template/src/ssr.js'),
};
}
// @remove-on-eject-end
diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js
index 9f3131b0660..6b7c9dd4c09 100644
--- a/packages/react-scripts/config/webpack.config.dev.js
+++ b/packages/react-scripts/config/webpack.config.dev.js
@@ -15,10 +15,14 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
-const eslintFormatter = require('react-dev-utils/eslintFormatter');
+// const eslintFormatter = require('react-dev-utils/eslintFormatter');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
+const sassFunctions = require('bpk-mixins/sass-functions');
+const camelCase = require('lodash/camelCase');
const getClientEnvironment = require('./env');
+const getLocalIdent = require('./getLocalIdent');
const paths = require('./paths');
+const pkgJson = require(paths.appPackageJson);
// Webpack uses `publicPath` to determine where the app is being served from.
// In development, we always serve from the root. This makes config easier.
@@ -30,6 +34,34 @@ const publicUrl = '';
// Get environment variables to inject into our app.
const env = getClientEnvironment(publicUrl);
+const bpkReactScriptsConfig = pkgJson['backpack-react-scripts'] || {};
+
+const customModuleRegexes = bpkReactScriptsConfig.babelIncludePrefixes
+ ? bpkReactScriptsConfig.babelIncludePrefixes.map(
+ prefix => new RegExp(`node_modules[\\/]${prefix}`)
+ )
+ : [];
+
+const optInCssModules = bpkReactScriptsConfig.cssModules === false;
+
+const postcssOptions = {
+ // Necessary for external CSS imports to work
+ // https://github.com/facebookincubator/create-react-app/issues/2677
+ ident: 'postcss',
+ plugins: () => [
+ require('postcss-flexbugs-fixes'),
+ autoprefixer({
+ browsers: [
+ '>1%',
+ 'last 4 versions',
+ 'Firefox ESR',
+ 'not ie < 9', // React doesn't support IE8 anyway
+ ],
+ flexbox: 'no-2009',
+ }),
+ ],
+};
+
// This is the development configuration.
// It is focused on developer experience and fast rebuilds.
// The production configuration is different and lives in a separate file.
@@ -40,27 +72,30 @@ module.exports = {
// These are the "entry points" to our application.
// This means they will be the "root" imports that are included in JS bundle.
// The first two entry points enable "hot" CSS and auto-refreshes for JS.
- entry: [
- // We ship a few polyfills by default:
- require.resolve('./polyfills'),
- // Include an alternative client for WebpackDevServer. A client's job is to
- // connect to WebpackDevServer by a socket and get notified about changes.
- // When you save a file, the client will either apply hot updates (in case
- // of CSS changes), or refresh the page (in case of JS changes). When you
- // make a syntax error, this client will display a syntax error overlay.
- // Note: instead of the default WebpackDevServer client, we use a custom one
- // to bring better experience for Create React App users. You can replace
- // the line below with these two lines if you prefer the stock client:
- // require.resolve('webpack-dev-server/client') + '?/',
- // require.resolve('webpack/hot/dev-server'),
- require.resolve('react-dev-utils/webpackHotDevClient'),
- // Finally, this is your app's code:
- paths.appIndexJs,
- // We include the app code last so that if there is a runtime error during
- // initialization, it doesn't blow up the WebpackDevServer client, and
- // changing JS code would still trigger a refresh.
- ],
+ entry: bpkReactScriptsConfig.disablePolyfills
+ ? [require.resolve('react-dev-utils/webpackHotDevClient'), paths.appIndexJs]
+ : [
+ // We ship a few polyfills by default:
+ require.resolve('./polyfills'),
+ // Include an alternative client for WebpackDevServer. A client's job is to
+ // connect to WebpackDevServer by a socket and get notified about changes.
+ // When you save a file, the client will either apply hot updates (in case
+ // of CSS changes), or refresh the page (in case of JS changes). When you
+ // make a syntax error, this client will display a syntax error overlay.
+ // Note: instead of the default WebpackDevServer client, we use a custom one
+ // to bring better experience for Create React App users. You can replace
+ // the line below with these two lines if you prefer the stock client:
+ // require.resolve('webpack-dev-server/client') + '?/',
+ // require.resolve('webpack/hot/dev-server'),
+ require.resolve('react-dev-utils/webpackHotDevClient'),
+ // Finally, this is your app's code:
+ paths.appIndexJs,
+ // We include the app code last so that if there is a runtime error during
+ // initialization, it doesn't blow up the WebpackDevServer client, and
+ // changing JS code would still trigger a refresh.
+ ],
output: {
+ jsonpFunction: camelCase(pkgJson.name + 'JsonpCallback'),
// Add /* filename */ comments to generated require()s in the output.
pathinfo: true,
// This does not produce a real file. It's just the virtual path that is
@@ -123,26 +158,36 @@ module.exports = {
// First, run the linter.
// It's important to do this before Babel processes the JS.
+ // {
+ // test: /\.(js|jsx|mjs)$/,
+ // enforce: 'pre',
+ // use: [
+ // {
+ // options: {
+ // formatter: eslintFormatter,
+ // eslintPath: require.resolve('eslint'),
+ // // @remove-on-eject-begin
+ // baseConfig: {
+ // extends: [require.resolve('eslint-config-react-app')],
+ // },
+ // ignore: false,
+ // useEslintrc: false,
+ // // @remove-on-eject-end
+ // },
+ // loader: require.resolve('eslint-loader'),
+ // },
+ // ],
+ // include: paths.appSrc,
+ // },
{
- test: /\.(js|jsx|mjs)$/,
- enforce: 'pre',
- use: [
- {
- options: {
- formatter: eslintFormatter,
- eslintPath: require.resolve('eslint'),
- // @remove-on-eject-begin
- baseConfig: {
- extends: [require.resolve('eslint-config-react-app')],
- },
- ignore: false,
- useEslintrc: false,
- // @remove-on-eject-end
- },
- loader: require.resolve('eslint-loader'),
- },
- ],
- include: paths.appSrc,
+ test: new RegExp(
+ `(^|/)(${(bpkReactScriptsConfig.amdExcludes || [])
+ .concat('lodash')
+ .join('|')})(/|.|$)`
+ ),
+ parser: {
+ amd: false,
+ },
},
{
// "oneOf" will traverse all following loaders until one will
@@ -163,7 +208,12 @@ module.exports = {
// Process JS with Babel.
{
test: /\.(js|jsx|mjs)$/,
- include: paths.appSrc,
+ include: [
+ paths.appSrc,
+ paths.backpackModulesRegex,
+ paths.saddlebagModulesRegex,
+ ...customModuleRegexes,
+ ],
loader: require.resolve('babel-loader'),
options: {
// @remove-on-eject-begin
@@ -182,34 +232,116 @@ module.exports = {
// In production, we use a plugin to extract that CSS to a file, but
// in development "style" loader enables hot editing of CSS.
{
- test: /\.css$/,
+ test: /\.scss$/,
+ exclude: optInCssModules
+ ? [/\.module\.scss$/, paths.backpackModulesRegex]
+ : [],
+ use: [
+ require.resolve('style-loader'),
+ {
+ loader: require.resolve('css-loader'),
+ options: {
+ importLoaders: 1,
+ modules: !optInCssModules,
+ localIdentName: '[local]-[hash:base64:5]',
+ getLocalIdent: getLocalIdent,
+ },
+ },
+ {
+ loader: require.resolve('postcss-loader'),
+ options: postcssOptions,
+ },
+ {
+ loader: require.resolve('sass-loader'),
+ options: {
+ functions: sassFunctions,
+ },
+ },
+ ],
+ },
+ {
+ test: {
+ and: [
+ () => optInCssModules,
+ {
+ or: [
+ /\.module\.scss$/,
+ { and: [paths.backpackModulesRegex, /\.scss$/] },
+ ],
+ },
+ ],
+ },
use: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 1,
+ modules: true,
+ localIdentName: '[local]-[hash:base64:5]',
+ getLocalIdent: getLocalIdent,
},
},
{
loader: require.resolve('postcss-loader'),
+ options: postcssOptions,
+ },
+ {
+ loader: require.resolve('sass-loader'),
+ options: {
+ functions: sassFunctions,
+ },
+ },
+ ],
+ },
+ {
+ test: /\.css$/,
+ exclude: optInCssModules
+ ? [/\.module\.css$/, paths.backpackModulesRegex]
+ : [],
+ use: [
+ require.resolve('style-loader'),
+ {
+ loader: require.resolve('css-loader'),
options: {
- // Necessary for external CSS imports to work
- // https://github.com/facebookincubator/create-react-app/issues/2677
- ident: 'postcss',
- plugins: () => [
- require('postcss-flexbugs-fixes'),
- autoprefixer({
- browsers: [
- '>1%',
- 'last 4 versions',
- 'Firefox ESR',
- 'not ie < 9', // React doesn't support IE8 anyway
- ],
- flexbox: 'no-2009',
- }),
+ importLoaders: 1,
+ modules: !optInCssModules,
+ localIdentName: '[local]-[hash:base64:5]',
+ getLocalIdent: getLocalIdent,
+ },
+ },
+ {
+ loader: require.resolve('postcss-loader'),
+ options: postcssOptions,
+ },
+ ],
+ },
+ {
+ test: {
+ and: [
+ () => optInCssModules,
+ {
+ or: [
+ /\.module\.css$/,
+ { and: [paths.backpackModulesRegex, /\.css$/] },
],
},
+ ],
+ },
+ use: [
+ require.resolve('style-loader'),
+ {
+ loader: require.resolve('css-loader'),
+ options: {
+ importLoaders: 1,
+ modules: true,
+ localIdentName: '[local]-[hash:base64:5]',
+ getLocalIdent: getLocalIdent,
+ },
+ },
+ {
+ loader: require.resolve('postcss-loader'),
+ options: postcssOptions,
},
],
},
diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js
index 3b2a2068db2..b3d94cde40d 100644
--- a/packages/react-scripts/config/webpack.config.prod.js
+++ b/packages/react-scripts/config/webpack.config.prod.js
@@ -15,11 +15,16 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
+const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
-const eslintFormatter = require('react-dev-utils/eslintFormatter');
+// const eslintFormatter = require('react-dev-utils/eslintFormatter');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
+const sassFunctions = require('bpk-mixins/sass-functions');
+const camelCase = require('lodash/camelCase');
const paths = require('./paths');
const getClientEnvironment = require('./env');
+const getLocalIdent = require('./getLocalIdent');
+const pkgJson = require(paths.appPackageJson);
// Webpack uses `publicPath` to determine where the app is being served from.
// It requires a trailing slash, or the file assets will get an incorrect path.
@@ -54,6 +59,35 @@ const extractTextPluginOptions = shouldUseRelativeAssetPaths
{ publicPath: Array(cssFilename.split('/').length).join('../') }
: {};
+const bpkReactScriptsConfig = pkgJson['backpack-react-scripts'] || {};
+
+const customModuleRegexes = bpkReactScriptsConfig.babelIncludePrefixes
+ ? bpkReactScriptsConfig.babelIncludePrefixes.map(
+ prefix => new RegExp(`node_modules[\\/]${prefix}`)
+ )
+ : [];
+
+const optInCssModules = bpkReactScriptsConfig.cssModules === false;
+const crossOriginLoading = bpkReactScriptsConfig.crossOriginLoading || false;
+
+const postcssOptions = {
+ // Necessary for external CSS imports to work
+ // https://github.com/facebookincubator/create-react-app/issues/2677
+ ident: 'postcss',
+ plugins: () => [
+ require('postcss-flexbugs-fixes'),
+ autoprefixer({
+ browsers: [
+ '>1%',
+ 'last 4 versions',
+ 'Firefox ESR',
+ 'not ie < 9', // React doesn't support IE8 anyway
+ ],
+ flexbox: 'no-2009',
+ }),
+ ],
+};
+
// This is the production configuration.
// It compiles slowly and is focused on producing a fast and minimal bundle.
// The development configuration is different and lives in a separate file.
@@ -64,8 +98,11 @@ module.exports = {
// You can exclude the *.map files from the build during deployment.
devtool: shouldUseSourceMap ? 'source-map' : false,
// In production, we only want to load the polyfills and the app code.
- entry: [require.resolve('./polyfills'), paths.appIndexJs],
+ entry: bpkReactScriptsConfig.disablePolyfills
+ ? paths.appIndexJs
+ : [require.resolve('./polyfills'), paths.appIndexJs],
output: {
+ jsonpFunction: camelCase(pkgJson.name + 'JsonpCallback'),
// The build folder.
path: paths.appBuild,
// Generated JS file names (with nested folders).
@@ -73,6 +110,7 @@ module.exports = {
// We don't currently advertise code splitting but Webpack supports it.
filename: 'static/js/[name].[chunkhash:8].js',
chunkFilename: 'static/js/[name].[chunkhash:8].chunk.js',
+ crossOriginLoading,
// We inferred the "public path" (such as / or /my-project) from homepage.
publicPath: publicPath,
// Point sourcemap entries to original disk location (format as URL on Windows)
@@ -81,6 +119,7 @@ module.exports = {
.relative(paths.appSrc, info.absoluteResourcePath)
.replace(/\\/g, '/'),
},
+ externals: bpkReactScriptsConfig.externals,
resolve: {
// This allows you to set a fallback for where Webpack should look for modules.
// We placed these paths second because we want `node_modules` to "win"
@@ -129,28 +168,38 @@ module.exports = {
// First, run the linter.
// It's important to do this before Babel processes the JS.
+ // {
+ // test: /\.(js|jsx|mjs)$/,
+ // enforce: 'pre',
+ // use: [
+ // {
+ // options: {
+ // formatter: eslintFormatter,
+ // eslintPath: require.resolve('eslint'),
+ // // @remove-on-eject-begin
+ // // TODO: consider separate config for production,
+ // // e.g. to enable no-console and no-debugger only in production.
+ // baseConfig: {
+ // extends: [require.resolve('eslint-config-react-app')],
+ // },
+ // ignore: false,
+ // useEslintrc: false,
+ // // @remove-on-eject-end
+ // },
+ // loader: require.resolve('eslint-loader'),
+ // },
+ // ],
+ // include: paths.appSrc,
+ // },
{
- test: /\.(js|jsx|mjs)$/,
- enforce: 'pre',
- use: [
- {
- options: {
- formatter: eslintFormatter,
- eslintPath: require.resolve('eslint'),
- // @remove-on-eject-begin
- // TODO: consider separate config for production,
- // e.g. to enable no-console and no-debugger only in production.
- baseConfig: {
- extends: [require.resolve('eslint-config-react-app')],
- },
- ignore: false,
- useEslintrc: false,
- // @remove-on-eject-end
- },
- loader: require.resolve('eslint-loader'),
- },
- ],
- include: paths.appSrc,
+ test: new RegExp(
+ `(^|/)(${(bpkReactScriptsConfig.amdExcludes || [])
+ .concat('lodash')
+ .join('|')})(/|.|$)`
+ ),
+ parser: {
+ amd: false,
+ },
},
{
// "oneOf" will traverse all following loaders until one will
@@ -170,7 +219,12 @@ module.exports = {
// Process JS with Babel.
{
test: /\.(js|jsx|mjs)$/,
- include: paths.appSrc,
+ include: [
+ paths.appSrc,
+ paths.backpackModulesRegex,
+ paths.saddlebagModulesRegex,
+ ...customModuleRegexes,
+ ],
loader: require.resolve('babel-loader'),
options: {
// @remove-on-eject-begin
@@ -192,8 +246,104 @@ module.exports = {
// tags. If you use code splitting, however, any async bundles will still
// use the "style" loader inside the async code so CSS from them won't be
// in the main CSS file.
+ {
+ test: /\.scss$/,
+ exclude: optInCssModules
+ ? [/\.module\.scss$/, paths.backpackModulesRegex]
+ : [],
+ loader: ExtractTextPlugin.extract(
+ Object.assign(
+ {
+ fallback: {
+ loader: require.resolve('style-loader'),
+ options: {
+ hmr: false,
+ },
+ },
+ use: [
+ {
+ loader: require.resolve('css-loader'),
+ options: {
+ importLoaders: 1,
+ minimize: true,
+ sourceMap: shouldUseSourceMap,
+ modules: !optInCssModules,
+ localIdentName: '[local]-[hash:base64:5]',
+ getLocalIdent: getLocalIdent,
+ },
+ },
+ {
+ loader: require.resolve('postcss-loader'),
+ options: postcssOptions,
+ },
+ {
+ loader: require.resolve('sass-loader'),
+ options: {
+ functions: sassFunctions,
+ },
+ },
+ ],
+ },
+ extractTextPluginOptions
+ )
+ ),
+ // Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
+ },
+ {
+ test: {
+ and: [
+ () => optInCssModules,
+ {
+ or: [
+ /\.module\.scss$/,
+ { and: [paths.backpackModulesRegex, /\.scss$/] },
+ ],
+ },
+ ],
+ },
+ loader: ExtractTextPlugin.extract(
+ Object.assign(
+ {
+ fallback: {
+ loader: require.resolve('style-loader'),
+ options: {
+ hmr: false,
+ },
+ },
+ use: [
+ {
+ loader: require.resolve('css-loader'),
+ options: {
+ importLoaders: 1,
+ minimize: true,
+ sourceMap: shouldUseSourceMap,
+ modules: true,
+ localIdentName: '[local]-[hash:base64:5]',
+ getLocalIdent: getLocalIdent,
+ },
+ },
+ {
+ loader: require.resolve('postcss-loader'),
+ options: postcssOptions,
+ },
+ {
+ loader: require.resolve('sass-loader'),
+ options: {
+ functions: sassFunctions,
+ },
+ },
+ ],
+ },
+ extractTextPluginOptions
+ )
+ ),
+ // Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
+ },
{
test: /\.css$/,
+ exclude: optInCssModules
+ ? [/\.module\.css$/, paths.backpackModulesRegex]
+ : [],
loader: ExtractTextPlugin.extract(
Object.assign(
{
@@ -210,28 +360,59 @@ module.exports = {
importLoaders: 1,
minimize: true,
sourceMap: shouldUseSourceMap,
+ modules: !optInCssModules,
+ localIdentName: '[local]-[hash:base64:5]',
+ getLocalIdent: getLocalIdent,
},
},
{
loader: require.resolve('postcss-loader'),
+ options: postcssOptions,
+ },
+ ],
+ },
+ extractTextPluginOptions
+ )
+ ),
+ // Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
+ },
+ {
+ test: {
+ and: [
+ () => optInCssModules,
+ {
+ or: [
+ /\.module\.css$/,
+ { and: [paths.backpackModulesRegex, /\.css$/] },
+ ],
+ },
+ ],
+ },
+ loader: ExtractTextPlugin.extract(
+ Object.assign(
+ {
+ fallback: {
+ loader: require.resolve('style-loader'),
+ options: {
+ hmr: false,
+ },
+ },
+ use: [
+ {
+ loader: require.resolve('css-loader'),
options: {
- // Necessary for external CSS imports to work
- // https://github.com/facebookincubator/create-react-app/issues/2677
- ident: 'postcss',
- plugins: () => [
- require('postcss-flexbugs-fixes'),
- autoprefixer({
- browsers: [
- '>1%',
- 'last 4 versions',
- 'Firefox ESR',
- 'not ie < 9', // React doesn't support IE8 anyway
- ],
- flexbox: 'no-2009',
- }),
- ],
+ importLoaders: 1,
+ minimize: true,
+ sourceMap: shouldUseSourceMap,
+ modules: true,
+ localIdentName: '[local]-[hash:base64:5]',
+ getLocalIdent: getLocalIdent,
},
},
+ {
+ loader: require.resolve('postcss-loader'),
+ options: postcssOptions,
+ },
],
},
extractTextPluginOptions
@@ -356,6 +537,20 @@ module.exports = {
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
// You can remove this if you don't use Moment.js:
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
+ new OptimizeCssAssetsPlugin({
+ cssProcessorOptions: {
+ postcssZindex: {
+ disable: true,
+ },
+ autoprefixer: { disable: true },
+ postcssDiscardComments: {
+ disable: true,
+ },
+ map: {
+ inline: false,
+ },
+ },
+ }),
],
// Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works.
diff --git a/packages/react-scripts/config/webpack.config.ssr.js b/packages/react-scripts/config/webpack.config.ssr.js
new file mode 100644
index 00000000000..6e6fcc82978
--- /dev/null
+++ b/packages/react-scripts/config/webpack.config.ssr.js
@@ -0,0 +1,567 @@
+// @remove-on-eject-begin
+/**
+ * Copyright (c) 2015-present, Facebook, Inc.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+// @remove-on-eject-end
+'use strict';
+
+const autoprefixer = require('autoprefixer');
+const path = require('path');
+const webpack = require('webpack');
+// const HtmlWebpackPlugin = require('html-webpack-plugin');
+const ExtractTextPlugin = require('extract-text-webpack-plugin');
+// const ManifestPlugin = require('webpack-manifest-plugin');
+// const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
+const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
+// const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
+// const eslintFormatter = require('react-dev-utils/eslintFormatter');
+const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
+const sassFunctions = require('bpk-mixins/sass-functions');
+// const camelCase = require('lodash/camelCase');
+const paths = require('./paths');
+const getClientEnvironment = require('./env');
+const getLocalIdent = require('./getLocalIdent');
+const pkgJson = require(paths.appPackageJson);
+
+// Webpack uses `publicPath` to determine where the app is being served from.
+// It requires a trailing slash, or the file assets will get an incorrect path.
+const publicPath = paths.servedPath;
+// Some apps do not use client-side routing with pushState.
+// For these, "homepage" can be set to "." to enable relative asset paths.
+const shouldUseRelativeAssetPaths = publicPath === './';
+// Source maps are resource heavy and can cause out of memory issue for large source files.
+const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
+// `publicUrl` is just like `publicPath`, but we will provide it to our app
+// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
+// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
+const publicUrl = publicPath.slice(0, -1);
+// Get environment variables to inject into our app.
+const env = getClientEnvironment(publicUrl);
+
+// Assert this just to be safe.
+// Development builds of React are slow and not intended for production.
+if (env.stringified['process.env'].NODE_ENV !== '"production"') {
+ throw new Error('Production builds must have NODE_ENV=production.');
+}
+
+// Note: defined here because it will be used more than once.
+const cssFilename = 'static/css/[name].[contenthash:8].css';
+
+// ExtractTextPlugin expects the build output to be flat.
+// (See https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/27)
+// However, our output is structured with css, js and media folders.
+// To have this structure working with relative paths, we have to use custom options.
+const extractTextPluginOptions = shouldUseRelativeAssetPaths
+ ? // Making sure that the publicPath goes back to to build folder.
+ { publicPath: Array(cssFilename.split('/').length).join('../') }
+ : {};
+
+const bpkReactScriptsConfig = pkgJson['backpack-react-scripts'] || {};
+
+const customModuleRegexes = bpkReactScriptsConfig.babelIncludePrefixes
+ ? bpkReactScriptsConfig.babelIncludePrefixes.map(
+ prefix => new RegExp(`node_modules[\\/]${prefix}`)
+ )
+ : [];
+
+const optInCssModules = bpkReactScriptsConfig.cssModules === false;
+// const crossOriginLoading = bpkReactScriptsConfig.crossOriginLoading || false;
+
+const postcssOptions = {
+ // Necessary for external CSS imports to work
+ // https://github.com/facebookincubator/create-react-app/issues/2677
+ ident: 'postcss',
+ plugins: () => [
+ require('postcss-flexbugs-fixes'),
+ autoprefixer({
+ browsers: [
+ '>1%',
+ 'last 4 versions',
+ 'Firefox ESR',
+ 'not ie < 9', // React doesn't support IE8 anyway
+ ],
+ flexbox: 'no-2009',
+ }),
+ ],
+};
+
+// This is the production configuration.
+// It compiles slowly and is focused on producing a fast and minimal bundle.
+// The development configuration is different and lives in a separate file.
+module.exports = {
+ // Don't attempt to continue if there are any errors.
+ bail: true,
+ // We generate sourcemaps in production. This is slow but gives good results.
+ // You can exclude the *.map files from the build during deployment.
+ // devtool: shouldUseSourceMap ? 'source-map' : false,
+ // In production, we only want to load the polyfills and the app code.
+ // entry: bpkReactScriptsConfig.disablePolyfills
+ // ? paths.appIndexJs
+ // : [require.resolve('./polyfills'), paths.appIndexJs],
+ entry: paths.appSsrJs,
+ target: 'node',
+ output: {
+ // jsonpFunction: camelCase(pkgJson.name + 'JsonpCallback'),
+ // The build folder.
+ path: paths.appBuild,
+ // Generated JS file names (with nested folders).
+ // There will be one main bundle, and one file per asynchronous chunk.
+ // We don't currently advertise code splitting but Webpack supports it.
+ // filename: 'static/js/[name].[chunkhash:8].js',
+ // chunkFilename: 'static/js/[name].[chunkhash:8].chunk.js',
+ // crossOriginLoading,
+ filename: 'ssr.js',
+ // We inferred the "public path" (such as / or /my-project) from homepage.
+ // publicPath: publicPath,
+ libraryTarget: 'commonjs2',
+ // Point sourcemap entries to original disk location (format as URL on Windows)
+ devtoolModuleFilenameTemplate: info =>
+ path
+ .relative(paths.appSrc, info.absoluteResourcePath)
+ .replace(/\\/g, '/'),
+ },
+ // externals: bpkReactScriptsConfig.externals,
+ externals: bpkReactScriptsConfig.ssrExternals || [],
+ resolve: {
+ // This allows you to set a fallback for where Webpack should look for modules.
+ // We placed these paths second because we want `node_modules` to "win"
+ // if there are any conflicts. This matches Node resolution mechanism.
+ // https://github.com/facebookincubator/create-react-app/issues/253
+ modules: ['node_modules', paths.appNodeModules].concat(
+ // It is guaranteed to exist because we tweak it in `env.js`
+ process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
+ ),
+ // These are the reasonable defaults supported by the Node ecosystem.
+ // We also include JSX as a common component filename extension to support
+ // some tools, although we do not recommend using it, see:
+ // https://github.com/facebookincubator/create-react-app/issues/290
+ // `web` extension prefixes have been added for better support
+ // for React Native Web.
+ extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'],
+ alias: {
+ // @remove-on-eject-begin
+ // Resolve Babel runtime relative to react-scripts.
+ // It usually still works on npm 3 without this but it would be
+ // unfortunate to rely on, as react-scripts could be symlinked,
+ // and thus babel-runtime might not be resolvable from the source.
+ 'babel-runtime': path.dirname(
+ require.resolve('babel-runtime/package.json')
+ ),
+ // @remove-on-eject-end
+ // Support React Native Web
+ // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
+ 'react-native': 'react-native-web',
+ },
+ plugins: [
+ // Prevents users from importing files from outside of src/ (or node_modules/).
+ // This often causes confusion because we only process files within src/ with babel.
+ // To fix this, we prevent you from importing files out of src/ -- if you'd like to,
+ // please link the files into your node_modules/ and let module-resolution kick in.
+ // Make sure your source files are compiled, as they will not be processed in any way.
+ new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
+ ],
+ },
+ module: {
+ strictExportPresence: true,
+ rules: [
+ // TODO: Disable require.ensure as it's not a standard language feature.
+ // We are waiting for https://github.com/facebookincubator/create-react-app/issues/2176.
+ // { parser: { requireEnsure: false } },
+
+ // First, run the linter.
+ // It's important to do this before Babel processes the JS.
+ // {
+ // test: /\.(js|jsx|mjs)$/,
+ // enforce: 'pre',
+ // use: [
+ // {
+ // options: {
+ // formatter: eslintFormatter,
+ // eslintPath: require.resolve('eslint'),
+ // // @remove-on-eject-begin
+ // // TODO: consider separate config for production,
+ // // e.g. to enable no-console and no-debugger only in production.
+ // baseConfig: {
+ // extends: [require.resolve('eslint-config-react-app')],
+ // },
+ // ignore: false,
+ // useEslintrc: false,
+ // // @remove-on-eject-end
+ // },
+ // loader: require.resolve('eslint-loader'),
+ // },
+ // ],
+ // include: paths.appSrc,
+ // },
+ {
+ test: new RegExp(
+ `(^|/)(${(bpkReactScriptsConfig.amdExcludes || [])
+ .concat('lodash')
+ .join('|')})(/|.|$)`
+ ),
+ parser: {
+ amd: false,
+ },
+ },
+ {
+ // "oneOf" will traverse all following loaders until one will
+ // match the requirements. When no loader matches it will fall
+ // back to the "file" loader at the end of the loader list.
+ oneOf: [
+ // "url" loader works just like "file" loader but it also embeds
+ // assets smaller than specified size as data URLs to avoid requests.
+ {
+ test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
+ loader: require.resolve('url-loader'),
+ options: {
+ limit: 10000,
+ name: 'static/media/[name].[hash:8].[ext]',
+ },
+ },
+ // Process JS with Babel.
+ {
+ test: /\.(js|jsx|mjs)$/,
+ include: [
+ paths.appSrc,
+ paths.backpackModulesRegex,
+ paths.saddlebagModulesRegex,
+ ...customModuleRegexes,
+ ],
+ loader: require.resolve('babel-loader'),
+ options: {
+ // @remove-on-eject-begin
+ babelrc: false,
+ presets: [require.resolve('babel-preset-react-app')],
+ // @remove-on-eject-end
+ compact: true,
+ },
+ },
+ // The notation here is somewhat confusing.
+ // "postcss" loader applies autoprefixer to our CSS.
+ // "css" loader resolves paths in CSS and adds assets as dependencies.
+ // "style" loader normally turns CSS into JS modules injecting