Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/config/webpack.config.js
'use strict'; | 'use strict'; | ||||
const darkTheme = require('@ant-design/dark-theme'); | |||||
const fs = require('fs'); | const fs = require('fs'); | ||||
const isWsl = require('is-wsl'); | const isWsl = require('is-wsl'); | ||||
const path = require('path'); | const path = require('path'); | ||||
const webpack = require('webpack'); | const webpack = require('webpack'); | ||||
const resolve = require('resolve'); | const resolve = require('resolve'); | ||||
const PnpWebpackPlugin = require('pnp-webpack-plugin'); | const PnpWebpackPlugin = require('pnp-webpack-plugin'); | ||||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||||
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); | const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); | ||||
const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin'); | const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin'); | ||||
const TerserPlugin = require('terser-webpack-plugin'); | const TerserPlugin = require('terser-webpack-plugin'); | ||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | ||||
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); | const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); | ||||
const safePostCssParser = require('postcss-safe-parser'); | const safePostCssParser = require('postcss-safe-parser'); | ||||
const ManifestPlugin = require('webpack-manifest-plugin'); | const ManifestPlugin = require('webpack-manifest-plugin'); | ||||
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); | const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); | ||||
const WorkboxWebpackPlugin = require('workbox-webpack-plugin'); | |||||
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin'); | const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin'); | ||||
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin'); | const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin'); | ||||
const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent'); | const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent'); | ||||
const paths = require('./paths'); | const paths = require('./paths'); | ||||
const modules = require('./modules'); | const modules = require('./modules'); | ||||
const getClientEnvironment = require('./env'); | const getClientEnvironment = require('./env'); | ||||
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin'); | const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin'); | ||||
const ForkTsCheckerWebpackPlugin = require('react-dev-utils/ForkTsCheckerWebpackPlugin'); | const ForkTsCheckerWebpackPlugin = require('react-dev-utils/ForkTsCheckerWebpackPlugin'); | ||||
const typescriptFormatter = require('react-dev-utils/typescriptFormatter'); | const typescriptFormatter = require('react-dev-utils/typescriptFormatter'); | ||||
const eslint = require('eslint'); | |||||
const workboxPlugin = require('workbox-webpack-plugin'); | const workboxPlugin = require('workbox-webpack-plugin'); | ||||
const postcssNormalize = require('postcss-normalize'); | const postcssNormalize = require('postcss-normalize'); | ||||
const hooks = require('html-webpack-plugin/lib/hooks'); | |||||
const appPackageJson = require(paths.appPackageJson); | const appPackageJson = require(paths.appPackageJson); | ||||
// Source maps are resource heavy and can cause out of memory issue for large source files. | // Source maps are resource heavy and can cause out of memory issue for large source files. | ||||
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false'; | const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false'; | ||||
// Some apps do not need the benefits of saving a web request, so not inlining the chunk | // Some apps do not need the benefits of saving a web request, so not inlining the chunk | ||||
// makes for a smoother build process. | // makes for a smoother build process. | ||||
const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false'; | const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false'; | ||||
Show All 11 Lines | |||||
const sassRegex = /\.(scss|sass)$/; | const sassRegex = /\.(scss|sass)$/; | ||||
const sassModuleRegex = /\.module\.(scss|sass)$/; | const sassModuleRegex = /\.module\.(scss|sass)$/; | ||||
// This is the production and development configuration. | // This is the production and development configuration. | ||||
// It is focused on developer experience, fast rebuilds, and a minimal bundle. | // It is focused on developer experience, fast rebuilds, and a minimal bundle. | ||||
module.exports = function (webpackEnv) { | module.exports = function (webpackEnv) { | ||||
const isEnvDevelopment = webpackEnv === 'development'; | const isEnvDevelopment = webpackEnv === 'development'; | ||||
const isEnvProduction = webpackEnv === 'production'; | const isEnvProduction = webpackEnv === 'production'; | ||||
const ESLintPlugin = require('eslint-webpack-plugin'); | |||||
module.exports = { | |||||
plugins: [new ESLintPlugin()], | |||||
}; | |||||
// Webpack uses `publicPath` to determine where the app is being served from. | // 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. | // It requires a trailing slash, or the file assets will get an incorrect path. | ||||
// In development, we always serve from the root. This makes config easier. | // In development, we always serve from the root. This makes config easier. | ||||
const publicPath = isEnvProduction | const publicPath = isEnvProduction | ||||
? paths.servedPath | ? paths.servedPath | ||||
: isEnvDevelopment && '/'; | : isEnvDevelopment && '/'; | ||||
// Some apps do not use client-side routing with pushState. | // Some apps do not use client-side routing with pushState. | ||||
▲ Show 20 Lines • Show All 367 Lines • ▼ Show 20 Lines | return { | ||||
PnpWebpackPlugin.moduleLoader(module), | PnpWebpackPlugin.moduleLoader(module), | ||||
], | ], | ||||
}, | }, | ||||
module: { | module: { | ||||
strictExportPresence: true, | strictExportPresence: true, | ||||
rules: [ | rules: [ | ||||
// Disable require.ensure as it's not a standard language feature. | // Disable require.ensure as it's not a standard language feature. | ||||
{ parser: { requireEnsure: false } }, | { parser: { requireEnsure: false } }, | ||||
// First, run the linter. | |||||
// It's important to do this before Babel processes the JS. | |||||
{ | |||||
test: /\.(js|mjs|jsx|ts|tsx)$/, | |||||
enforce: 'pre', | |||||
use: [ | |||||
{ | |||||
options: { | |||||
cache: true, | |||||
formatter: require.resolve( | |||||
'react-dev-utils/eslintFormatter', | |||||
), | |||||
eslintPath: require.resolve('eslint'), | |||||
resolvePluginsRelativeTo: __dirname, | |||||
}, | |||||
loader: require.resolve('eslint-loader'), | |||||
}, | |||||
], | |||||
include: paths.appSrc, | |||||
}, | |||||
{ | { | ||||
// "oneOf" will traverse all following loaders until one will | // "oneOf" will traverse all following loaders until one will | ||||
// match the requirements. When no loader matches it will fall | // match the requirements. When no loader matches it will fall | ||||
// back to the "file" loader at the end of the loader list. | // back to the "file" loader at the end of the loader list. | ||||
oneOf: [ | oneOf: [ | ||||
// "url" loader works like "file" loader except that it embeds assets | // "url" loader works like "file" loader except that it embeds assets | ||||
// smaller than specified limit in bytes as data URLs to avoid requests. | // smaller than specified limit in bytes as data URLs to avoid requests. | ||||
// A missing `test` is equivalent to a match. | // A missing `test` is equivalent to a match. | ||||
▲ Show 20 Lines • Show All 326 Lines • Show Last 20 Lines |