Skip to content

Custom react scripts #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions packages/react-scripts/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');
// @remove-on-eject-end
const postcssNormalize = require('postcss-normalize');

const BUILD_ID = process.env.REACT_APP_BUILD_ID || '';

const appPackageJson = require(paths.appPackageJson);

// Source maps are resource heavy and can cause out of memory issue for large source files.
Expand Down Expand Up @@ -184,14 +186,14 @@ module.exports = function(webpackEnv) {
// There will be one main bundle, and one file per asynchronous chunk.
// In development, it does not produce real files.
filename: isEnvProduction
? 'static/js/[name].[contenthash:8].js'
: isEnvDevelopment && 'static/js/bundle.js',
? `static-${BUILD_ID}/js/[name].[contenthash:8].js`
: isEnvDevelopment && `static-${BUILD_ID}/js/bundle.js`,
// TODO: remove this when upgrading to webpack 5
futureEmitAssets: true,
// There are also additional JS chunk files if you use code splitting.
chunkFilename: isEnvProduction
? 'static/js/[name].[contenthash:8].chunk.js'
: isEnvDevelopment && 'static/js/[name].chunk.js',
? `static-${BUILD_ID}/js/[name].[contenthash:8].chunk.js`
: isEnvDevelopment && `static-${BUILD_ID}/js/[name].chunk.js`,
// We inferred the "public path" (such as / or /my-project) from homepage.
// We use "/" in development.
publicPath: publicPath,
Expand Down Expand Up @@ -396,7 +398,7 @@ module.exports = function(webpackEnv) {
loader: require.resolve('url-loader'),
options: {
limit: imageInlineSizeLimit,
name: 'static/media/[name].[hash:8].[ext]',
name: `static-${BUILD_ID}/media/[name].[hash:8].[ext]`,
},
},
// Process application JS with Babel.
Expand Down Expand Up @@ -570,7 +572,7 @@ module.exports = function(webpackEnv) {
// by webpacks internal loaders.
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
options: {
name: 'static/media/[name].[hash:8].[ext]',
name: `static-${BUILD_ID}/media/[name].[hash:8].[ext]`,
},
},
// ** STOP ** Are you adding a new loader?
Expand Down Expand Up @@ -644,8 +646,8 @@ module.exports = function(webpackEnv) {
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: 'static/css/[name].[contenthash:8].css',
chunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
filename: `static-${BUILD_ID}/css/[name].[contenthash:8].css`,
chunkFilename: `static-${BUILD_ID}/css/[name].[contenthash:8].chunk.css`,
}),
// Generate an asset manifest file with the following content:
// - "files" key: Mapping of all asset filenames to their corresponding
Expand Down
10 changes: 5 additions & 5 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "react-scripts",
"version": "3.3.0",
"description": "Configuration and scripts for Create React App.",
"name": "xometry-react-scripts",
"version": "3.3.1",
"description": "Xometry configuration and scripts for Create React App.",
"repository": {
"type": "git",
"url": "https://github.com/facebook/create-react-app.git",
"url": "https://github.com/xometry/create-react-app.git",
"directory": "packages/react-scripts"
},
"license": "MIT",
"engines": {
"node": ">=8.10"
},
"bugs": {
"url": "https://github.com/facebook/create-react-app/issues"
"url": "https://github.com/xometry/create-react-app/issues"
},
"files": [
"bin",
Expand Down