| | |
| | | 'use strict'; |
| | | // 'use strict'; |
| | | |
| | | const fs = require('fs'); |
| | | const isWsl = require('is-wsl'); |
| | |
| | | const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin'); |
| | | const ForkTsCheckerWebpackPlugin = require('react-dev-utils/ForkTsCheckerWebpackPlugin'); |
| | | const typescriptFormatter = require('react-dev-utils/typescriptFormatter'); |
| | | const eslint = require('eslint'); |
| | | // const eslint = require('eslint'); |
| | | |
| | | const postcssNormalize = require('postcss-normalize'); |
| | | |
| | |
| | | const cssModuleRegex = /\.module\.css$/; |
| | | const sassRegex = /\.(scss|sass)$/; |
| | | const sassModuleRegex = /\.module\.(scss|sass)$/; |
| | | const sign = (() => { |
| | | let uuid = [] |
| | | let options = '0123456789abcdefghigklmnopqrstuv' |
| | | for (let i = 0; i < 8; i++) { |
| | | uuid.push(options.substr(Math.floor(Math.random() * 0x20), 1)) |
| | | } |
| | | return uuid.join('') |
| | | })() |
| | | |
| | | // src => @ |
| | | function resolves(dir) { |
| | |
| | | pathinfo: isEnvDevelopment, |
| | | // There will be one main bundle, and one file per asynchronous chunk. |
| | | // In development, it does not produce real files. |
| | | // contenthash => hash |
| | | filename: isEnvProduction |
| | | ? 'static/js/[name].[contenthash:8].js' |
| | | ? `static/js/[name].${sign}.js` |
| | | : isEnvDevelopment && 'static/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. |
| | | // contenthash => hash |
| | | chunkFilename: isEnvProduction |
| | | ? 'static/js/[name].[contenthash:8].chunk.js' |
| | | ? `static/js/[name].${sign}.chunk.js` |
| | | : isEnvDevelopment && 'static/js/[name].chunk.js', |
| | | // We inferred the "public path" (such as / or /my-project) from homepage. |
| | | // We use "/" in development. |
| | |
| | | loader: require.resolve('url-loader'), |
| | | options: { |
| | | limit: imageInlineSizeLimit, |
| | | name: 'static/media/[name].[hash:8].[ext]', |
| | | name: `static/media/[name].${sign}.[ext]`, |
| | | }, |
| | | }, |
| | | // Process application JS with Babel. |
| | |
| | | // by webpacks internal loaders. |
| | | exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/], |
| | | options: { |
| | | name: 'static/media/[name].[hash:8].[ext]', |
| | | name: `static/media/[name].${sign}.[ext]`, |
| | | }, |
| | | }, |
| | | // ** STOP ** Are you adding a new loader? |
| | |
| | | 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', |
| | | // contenthash => hash |
| | | filename: `static/css/[name].${sign}.css`, |
| | | chunkFilename: `static/css/[name].${sign}.chunk.css`, |
| | | }), |
| | | // Generate a manifest file which contains a mapping of all asset filenames |
| | | // to their corresponding output file so that tools can pick it up without |