Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
? addWebpackPlugin(
// https://docs.sentry.io/platforms/javascript/guides/react/sourcemaps/
new SentryWebpackPlugin({
// sentry-cli configuration
authToken: process.env.SENTRY_AUTH_TOKEN,
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
release: process.env.REACT_APP_NAME + "@" + process.env.REACT_APP_VERSION,
// webpack specific configuration
include: ".",
ignore: ["node_modules", "webpack.config.js"],
}),
)
: undefined,
addWebpackAlias({
"@apiType": resolve(
`src/api/${
process.env.REACT_APP_USE_MOCK_API === "true" || process.env.NODE_ENV === "test" ? "mockApi" : "realApi"
}`,
),
}),
// addWebpackPlugin(new BundleAnalyzerPlugin()),
);
return config;
};
/**
* react-app-rewired configuration file
*
* Theses functions are used to override the configurations provided by
* create-react-app to be able to tweak it without ejecting the
* project. Be careful!
*/
module.exports = {
webpack: override(
babelInclude([path.resolve('src'), path.resolve('packages')]),
useEslintRc(),
removeModuleScopePlugin(),
addWebpackAlias(lernaAlias.webpack())
),
jest: config => {
// create-react-app looks for tests in `src`, we look in `packages`
config.roots = ['/packages'];
config.testMatch = config.testMatch.map(m => m.replace('src', 'packages'));
config.collectCoverageFrom = ['**/packages/**/*.js'];
config.coveragePathIgnorePatterns = ['/dist/'];
// we tell Jest to import the @quid packages from their source directory
// rather than from the dist one, so we don't have to build them each time
config.moduleNameMapper = lernaAlias.jest();
return config;
},
};
//@ts-check
'use strict';
const { addWebpackPlugin, override, useBabelRc, addWebpackAlias } = require('customize-cra');
const MonacoEditorWebpackPlugin = require('monaco-editor-webpack-plugin');
const WorkerPlugin = require('worker-plugin');
module.exports = override(
addWebpackPlugin(new MonacoEditorWebpackPlugin()),
addWebpackPlugin(new WorkerPlugin()),
useBabelRc(),
addWebpackAlias({
'@velcro/bundler': '@velcro/bundler/dist/dist-module/index.js',
'@velcro/resolver-host-compound': '@velcro/resolver-host-compound/dist/dist-module/index.js',
'@velcro/resolver-host-unpkg': '@velcro/resolver-host-unpkg/dist/dist-module/index.js',
'@velcro/resolver': '@velcro/resolver/dist/dist-module/index.js',
})
);
override,
addDecoratorsLegacy,
disableEsLint,
addBundleVisualizer,
addWebpackAlias,
adjustWorkbox,
addLessLoader,
fixBabelImports
} = require('customize-cra');
const path = require('path');
module.exports = override(
addDecoratorsLegacy(),
disableEsLint(),
addBundleVisualizer({}, true),
addWebpackAlias({
'@': path.resolve(__dirname, 'src'),
components: path.resolve(__dirname, 'src/components'),
assets: path.resolve(__dirname, 'src/assets')
}),
adjustWorkbox(wb =>
Object.assign(wb, {
skipWaiting: true,
exclude: (wb.exclude || []).concat('index.html')
})
),
fixBabelImports('import', {
libraryName: 'antd',
style: true
}),
addLessLoader({
localIdentName: '[local]--[hash:base64:8]',
} = require('customize-cra')
module.exports = override(
(() => config => {
config.module.rules.push({
test: /\.worker\.js$/,
use: { loader: 'worker-loader', options: { inline: true } }
})
config.output.globalObject = 'this'
return config
})(),
removeModuleScopePlugin(),
babelInclude([path.resolve(__dirname, 'src'), path.resolve(__dirname, 'core')]),
addWebpackAlias({
['core']: path.resolve(__dirname, 'core')
})
)
const addLoadablePlugin = config => {
config.plugins.push(
new LoadablePlugin()
)
config.plugins[0].options.inject = false
return config
}
module.exports = override(
process.env.NODE_ENV === 'production' && addLoadablePlugin,
disableEsLint(),
...addBabelPlugins('transform-imports', '@loadable/babel-plugin', 'transform-react-remove-prop-types'),
addWebpackAlias({ ...aliases, 'lodash-es': 'lodash' }),
hasCustomConfigOverrides && require(appConfigOverrides)
)
const path = require("path");
const {
override,
addWebpackAlias,
addBabelPlugins,
addBundleVisualizer
} = require("customize-cra");
module.exports = {
webpack: override(
addWebpackAlias({
"#": path.resolve(__dirname, "./src"),
"react-dom": "@hot-loader/react-dom"
}),
addBundleVisualizer({}, true),
...addBabelPlugins("emotion", "react-hot-loader/babel")
),
jest: config => ({
...config,
setupFilesAfterEnv: ["/.jest/setup.js"],
moduleNameMapper: { "#(.*)$": "/src/$1" },
coverageDirectory: "/.coverage"
})
};
const { override, addWebpackAlias } = require("customize-cra");
const path = require("path");
module.exports = override(
addWebpackAlias({
"@": path.resolve(__dirname, "./src")
})
);
override,
addDecoratorsLegacy,
disableEsLint,
addBundleVisualizer,
addWebpackAlias,
adjustWorkbox,
addLessLoader,
fixBabelImports
} = require('customize-cra');
const path = require('path');
module.exports = override(
addDecoratorsLegacy(),
disableEsLint(),
process.env.BUNDLE_VISUALIZE === 1 && addBundleVisualizer(),
addWebpackAlias({
'@': path.resolve(__dirname, 'src'),
components: path.resolve(__dirname, 'src/components'),
assets: path.resolve(__dirname, 'src/assets')
}),
adjustWorkbox(wb =>
Object.assign(wb, {
skipWaiting: true,
exclude: (wb.exclude || []).concat('index.html')
})
),
fixBabelImports('import', {
libraryName: 'antd',
style: true
}),
addLessLoader({
localIdentName: '[local]--[hash:base64:8]',
module.exports = {
webpack: override(
fixBabelImports('import', {
libraryName: 'antd',
libraryDirectory: 'es',
style: 'css',
style: true
}),
addLessLoader({
javascriptEnabled: true,
modifyVars: {
'@primary-color': '#639'
}
}),
addWebpackAlias({
'@': resolveApp('src'),
'@module': resolveApp('node_modules'),
'@assets': resolveApp('src/assets'),
'@images': resolveApp('src/assets/images'),
'@fonts': resolveApp('src/assets/fonts'),
'@view': resolveApp('src/view'),
'@store': resolveApp('src/store'),
'@component': resolveApp('src/component'),
'@script': resolveApp('src/script')
}),
config => {
//自定义svg loader方式
const len = config.module.rules[2].oneOf.length
config.module.rules[2].oneOf[1].options.plugins.shift()
config.module.rules[2].oneOf[len - 1].exclude.push(/\.svg$/)
config.module.rules[2].oneOf.push({