Skip to content

Commit 7177a59

Browse files
committed
remove warning messages
1 parent 4f40f6f commit 7177a59

File tree

2 files changed

+33
-28
lines changed

2 files changed

+33
-28
lines changed

packages/react-scripts/config/webpack.config.dev.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
'use strict';
1212

1313
const autoprefixer = require('autoprefixer');
14-
const chalk = require('chalk');
1514
const path = require('path');
1615
const webpack = require('webpack');
1716
const HtmlWebpackPlugin = require('html-webpack-plugin');
@@ -36,13 +35,9 @@ const env = getClientEnvironment(publicUrl);
3635
// Get supported browsers list
3736
let supportedBrowsers = require(paths.appPackageJson).browserslist;
3837
if (!supportedBrowsers || Object.keys(supportedBrowsers).length === 0) {
39-
console.log(
40-
chalk.yellow(
41-
'You can now specify targeted browsers by adding "browserslist" key in "package.json" as per User Documentation'
42-
)
43-
);
4438
// Assign default browsers when browserslist is not specified
45-
supportedBrowsers = "browsers: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9', // React doesn't support IE8 anyway]";
39+
supportedBrowsers =
40+
"browsers: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9', // React doesn't support IE8 anyway]";
4641
}
4742

4843
// This is the development configuration.
@@ -90,9 +85,9 @@ module.exports = {
9085
chunkFilename: 'static/js/[name].chunk.js',
9186
// This is the URL that app is served from. We use "/" in development.
9287
publicPath: publicPath,
93-
// Point sourcemap entries to original disk location
88+
// Point sourcemap entries to original disk location (format as URL on Windows)
9489
devtoolModuleFilenameTemplate: info =>
95-
path.resolve(info.absoluteResourcePath),
90+
path.resolve(info.absoluteResourcePath).replace(/\\/g, '/'),
9691
},
9792
resolve: {
9893
// This allows you to set a fallback for where Webpack should look for modules.
@@ -107,7 +102,9 @@ module.exports = {
107102
// We also include JSX as a common component filename extension to support
108103
// some tools, although we do not recommend using it, see:
109104
// https://github.com/facebookincubator/create-react-app/issues/290
110-
extensions: ['.js', '.json', '.jsx'],
105+
// `web` extension prefixes have been added for better support
106+
// for React Native Web.
107+
extensions: ['.web.js', '.js', '.json', '.web.jsx', '.jsx'],
111108
alias: {
112109
// @remove-on-eject-begin
113110
// Resolve Babel runtime relative to react-scripts.
@@ -230,12 +227,11 @@ module.exports = {
230227
{
231228
loader: require.resolve('postcss-loader'),
232229
options: {
233-
ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options
234230
plugins: () => [
235231
require('postcss-flexbugs-fixes'),
236232
autoprefixer({
237-
flexbox: 'no-2009',
238233
supportedBrowsers,
234+
flexbox: 'no-2009',
239235
}),
240236
],
241237
},
@@ -257,6 +253,8 @@ module.exports = {
257253
inject: true,
258254
template: paths.appHtml,
259255
}),
256+
// Add module names to factory functions so they appear in browser profiler.
257+
new webpack.NamedModulesPlugin(),
260258
// Makes some environment variables available to the JS code, for example:
261259
// if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`.
262260
new webpack.DefinePlugin(env.stringified),
@@ -281,6 +279,7 @@ module.exports = {
281279
// Some libraries import Node modules but don't use them in the browser.
282280
// Tell Webpack to provide empty mocks for them so importing them works.
283281
node: {
282+
dgram: 'empty',
284283
fs: 'empty',
285284
net: 'empty',
286285
tls: 'empty',

packages/react-scripts/config/webpack.config.prod.js

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
'use strict';
1212

1313
const autoprefixer = require('autoprefixer');
14-
const chalk = require('chalk');
1514
const path = require('path');
1615
const webpack = require('webpack');
1716
const HtmlWebpackPlugin = require('html-webpack-plugin');
@@ -27,13 +26,9 @@ const getClientEnvironment = require('./env');
2726
// Get supported browsers list
2827
let supportedBrowsers = require(paths.appPackageJson).browserslist;
2928
if (!supportedBrowsers || Object.keys(supportedBrowsers).length === 0) {
30-
console.log(
31-
chalk.yellow(
32-
'You can now specify targeted browsers by adding "browserslist" key in "package.json" as per User Documentation'
33-
)
34-
);
3529
// Assign default browsers when browserslist is not specified
36-
supportedBrowsers = "browsers: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9', // React doesn't support IE8 anyway]";
30+
supportedBrowsers =
31+
"browsers: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9', // React doesn't support IE8 anyway]";
3732
}
3833

3934
// Webpack uses `publicPath` to determine where the app is being served from.
@@ -88,9 +83,11 @@ module.exports = {
8883
chunkFilename: 'static/js/[name].[chunkhash:8].chunk.js',
8984
// We inferred the "public path" (such as / or /my-project) from homepage.
9085
publicPath: publicPath,
91-
// Point sourcemap entries to original disk location
86+
// Point sourcemap entries to original disk location (format as URL on Windows)
9287
devtoolModuleFilenameTemplate: info =>
93-
path.relative(paths.appSrc, info.absoluteResourcePath),
88+
path
89+
.relative(paths.appSrc, info.absoluteResourcePath)
90+
.replace(/\\/g, '/'),
9491
},
9592
resolve: {
9693
// This allows you to set a fallback for where Webpack should look for modules.
@@ -105,7 +102,9 @@ module.exports = {
105102
// We also include JSX as a common component filename extension to support
106103
// some tools, although we do not recommend using it, see:
107104
// https://github.com/facebookincubator/create-react-app/issues/290
108-
extensions: ['.js', '.json', '.jsx'],
105+
// `web` extension prefixes have been added for better support
106+
// for React Native Web.
107+
extensions: ['.web.js', '.js', '.json', '.web.jsx', '.jsx'],
109108
alias: {
110109
// @remove-on-eject-begin
111110
// Resolve Babel runtime relative to react-scripts.
@@ -199,12 +198,13 @@ module.exports = {
199198
test: /\.(js|jsx)$/,
200199
include: paths.appSrc,
201200
loader: require.resolve('babel-loader'),
202-
// @remove-on-eject-begin
203201
options: {
202+
// @remove-on-eject-begin
204203
babelrc: false,
205204
presets: [require.resolve('babel-preset-react-app')],
205+
// @remove-on-eject-end
206+
compact: true,
206207
},
207-
// @remove-on-eject-end
208208
},
209209
// The notation here is somewhat confusing.
210210
// "postcss" loader applies autoprefixer to our CSS.
@@ -236,10 +236,10 @@ module.exports = {
236236
{
237237
loader: require.resolve('postcss-loader'),
238238
options: {
239-
ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options
240239
plugins: () => [
241240
require('postcss-flexbugs-fixes'),
242241
autoprefixer({
242+
supportedBrowsers,
243243
flexbox: 'no-2009',
244244
}),
245245
],
@@ -297,6 +297,9 @@ module.exports = {
297297
},
298298
output: {
299299
comments: false,
300+
// Turned on because emoji and regex is not minified properly using default
301+
// https://github.com/facebookincubator/create-react-app/issues/2488
302+
ascii_only: true,
300303
},
301304
sourceMap: true,
302305
}),
@@ -324,6 +327,11 @@ module.exports = {
324327
// This message occurs for every build and is a bit too noisy.
325328
return;
326329
}
330+
if (message.indexOf('Skipping static resource') === 0) {
331+
// This message obscures real errors so we ignore it.
332+
// https://github.com/facebookincubator/create-react-app/issues/2612
333+
return;
334+
}
327335
console.log(message);
328336
},
329337
minify: true,
@@ -334,9 +342,6 @@ module.exports = {
334342
navigateFallbackWhitelist: [/^(?!\/__).*/],
335343
// Don't precache sourcemaps (they're large) and build asset manifest:
336344
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
337-
// Work around Windows path issue in SWPrecacheWebpackPlugin:
338-
// https://github.com/facebookincubator/create-react-app/issues/2235
339-
stripPrefix: paths.appBuild.replace(/\\/g, '/') + '/',
340345
}),
341346
// Moment.js is an extremely popular library that bundles large locale files
342347
// by default due to how Webpack interprets its code. This is a practical
@@ -348,6 +353,7 @@ module.exports = {
348353
// Some libraries import Node modules but don't use them in the browser.
349354
// Tell Webpack to provide empty mocks for them so importing them works.
350355
node: {
356+
dgram: 'empty',
351357
fs: 'empty',
352358
net: 'empty',
353359
tls: 'empty',

0 commit comments

Comments
 (0)