|
10 | 10 |
|
11 | 11 | const path = require('path');
|
12 | 12 | const webpack = require('webpack');
|
13 |
| -const HtmlWebpackPlugin = require('html-webpack-plugin'); |
14 | 13 | const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
15 |
| -const ManifestPlugin = require('webpack-manifest-plugin'); |
16 |
| -const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); |
17 |
| -const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin'); |
18 | 14 | const eslintFormatter = require('react-dev-utils/eslintFormatter');
|
19 | 15 | const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
|
20 | 16 | const paths = require('./paths');
|
@@ -93,8 +89,8 @@ module.exports = {
|
93 | 89 | // Generated JS file names (with nested folders).
|
94 | 90 | // There will be one main bundle, and one file per asynchronous chunk.
|
95 | 91 | // We don't currently advertise code splitting but Webpack supports it.
|
96 |
| - filename: 'static/js/[name].[chunkhash:8].js', |
97 |
| - chunkFilename: 'static/js/[name].[chunkhash:8].chunk.js', |
| 92 | + filename: 'index.js', |
| 93 | + libraryTarget: 'commonjs', |
98 | 94 | // We inferred the "public path" (such as / or /my-project) from homepage.
|
99 | 95 | publicPath: publicPath,
|
100 | 96 | // Point sourcemap entries to original disk location (format as URL on Windows)
|
@@ -287,95 +283,15 @@ module.exports = {
|
287 | 283 | ],
|
288 | 284 | },
|
289 | 285 | plugins: [
|
290 |
| - // Makes some environment variables available in index.html. |
291 |
| - // The public URL is available as %PUBLIC_URL% in index.html, e.g.: |
292 |
| - // <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> |
293 |
| - // In production, it will be an empty string unless you specify "homepage" |
294 |
| - // in `package.json`, in which case it will be the pathname of that URL. |
295 |
| - new InterpolateHtmlPlugin(env.raw), |
296 |
| - // Generates an `index.html` file with the <script> injected. |
297 |
| - new HtmlWebpackPlugin({ |
298 |
| - inject: true, |
299 |
| - template: paths.appHtml, |
300 |
| - minify: { |
301 |
| - removeComments: true, |
302 |
| - collapseWhitespace: true, |
303 |
| - removeRedundantAttributes: true, |
304 |
| - useShortDoctype: true, |
305 |
| - removeEmptyAttributes: true, |
306 |
| - removeStyleLinkTypeAttributes: true, |
307 |
| - keepClosingSlash: true, |
308 |
| - minifyJS: true, |
309 |
| - minifyCSS: true, |
310 |
| - minifyURLs: true, |
311 |
| - }, |
312 |
| - }), |
313 | 286 | // Makes some environment variables available to the JS code, for example:
|
314 | 287 | // if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
|
315 | 288 | // It is absolutely essential that NODE_ENV was set to production here.
|
316 | 289 | // Otherwise React will be compiled in the very slow development mode.
|
317 | 290 | new webpack.DefinePlugin(env.stringified),
|
318 |
| - // Minify the code. |
319 |
| - new webpack.optimize.UglifyJsPlugin({ |
320 |
| - compress: { |
321 |
| - warnings: false, |
322 |
| - // Disabled because of an issue with Uglify breaking seemingly valid code: |
323 |
| - // https://github.com/facebookincubator/create-react-app/issues/2376 |
324 |
| - // Pending further investigation: |
325 |
| - // https://github.com/mishoo/UglifyJS2/issues/2011 |
326 |
| - comparisons: false, |
327 |
| - }, |
328 |
| - mangle: { |
329 |
| - safari10: true, |
330 |
| - }, |
331 |
| - output: { |
332 |
| - comments: false, |
333 |
| - // Turned on because emoji and regex is not minified properly using default |
334 |
| - // https://github.com/facebookincubator/create-react-app/issues/2488 |
335 |
| - ascii_only: true, |
336 |
| - }, |
337 |
| - sourceMap: shouldUseSourceMap, |
338 |
| - }), |
339 | 291 | // Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
|
340 | 292 | new ExtractTextPlugin({
|
341 | 293 | filename: cssFilename,
|
342 | 294 | }),
|
343 |
| - // Generate a manifest file which contains a mapping of all asset filenames |
344 |
| - // to their corresponding output file so that tools can pick it up without |
345 |
| - // having to parse `index.html`. |
346 |
| - new ManifestPlugin({ |
347 |
| - fileName: 'asset-manifest.json', |
348 |
| - }), |
349 |
| - // Generate a service worker script that will precache, and keep up to date, |
350 |
| - // the HTML & assets that are part of the Webpack build. |
351 |
| - new SWPrecacheWebpackPlugin({ |
352 |
| - // By default, a cache-busting query parameter is appended to requests |
353 |
| - // used to populate the caches, to ensure the responses are fresh. |
354 |
| - // If a URL is already hashed by Webpack, then there is no concern |
355 |
| - // about it being stale, and the cache-busting can be skipped. |
356 |
| - dontCacheBustUrlsMatching: /\.\w{8}\./, |
357 |
| - filename: 'service-worker.js', |
358 |
| - logger(message) { |
359 |
| - if (message.indexOf('Total precache size is') === 0) { |
360 |
| - // This message occurs for every build and is a bit too noisy. |
361 |
| - return; |
362 |
| - } |
363 |
| - if (message.indexOf('Skipping static resource') === 0) { |
364 |
| - // This message obscures real errors so we ignore it. |
365 |
| - // https://github.com/facebookincubator/create-react-app/issues/2612 |
366 |
| - return; |
367 |
| - } |
368 |
| - console.log(message); |
369 |
| - }, |
370 |
| - minify: true, |
371 |
| - // For unknown URLs, fallback to the index page |
372 |
| - navigateFallback: publicUrl + '/index.html', |
373 |
| - // Ignores URLs starting from /__ (useful for Firebase): |
374 |
| - // https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219 |
375 |
| - navigateFallbackWhitelist: [/^(?!\/__).*/], |
376 |
| - // Don't precache sourcemaps (they're large) and build asset manifest: |
377 |
| - staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/], |
378 |
| - }), |
379 | 295 | // Moment.js is an extremely popular library that bundles large locale files
|
380 | 296 | // by default due to how Webpack interprets its code. This is a practical
|
381 | 297 | // solution that requires the user to opt into importing specific locales.
|
|
0 commit comments