Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { override, babelInclude, addWebpackAlias } = require("customize-cra");
const resolve = (...dest) => {
return path.resolve(__dirname, ...dest);
};
const getAliasForCommonLibraries = (modules) => {
return modules.reduce((obj, name) => {
return Object.assign(obj, {
[name]: resolve("node_modules", name),
});
}, {});
};
module.exports = override(
babelInclude([
resolve("src"), // make sure you link your own source
// resolve("node_modules", "@spax"),
]),
addWebpackAlias(getAliasForCommonLibraries([
"react",
"react-dom",
"react-hot-loader",
"react-router-dom",
"@material-ui/core",
"@material-ui/icons",
"@types/node",
"@types/react",
"@types/react-dom",
"@types/react-router-dom"
])),
);
config.resolve.plugins = config.resolve.plugins.filter(
p => p.constructor.name !== 'ModuleScopePlugin'
);
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;
disableEsLint,
override,
} = require('customize-cra');
// TODO: Replace with official plugin when it is supported
const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
module.exports = override(
// Add support for React Fast Refresh
process.env.NODE_ENV === 'development'
? addBabelPlugin('react-refresh/babel')
: undefined,
process.env.NODE_ENV === 'development'
? addWebpackPlugin(new ReactRefreshPlugin())
: undefined,
// Add support for transpiling local package imports
babelInclude([
path.resolve('src'),
path.resolve('../backend'),
path.resolve('../universal'),
]),
babelExclude([
path.resolve('../backend/node_modules'),
path.resolve('../universal/node_modules'),
]),
// Disable CRA lint in favour of project lint
disableEsLint(),
);
const { override, fixBabelImports, addBundleVisualizer, addLessLoader, disableEsLint, babelInclude, addWebpackResolve } = require('customize-cra');
const path = require('path');
module.exports = override(
// 模块 解析 路径
// addWebpackResolve({
// modules: [
// path.resolve(path.dirname(path.dirname(process.cwd())), 'node_modules'),
// path.resolve(process.cwd(), 'node_modules'),
// path.resolve(process.cwd(), 'src'),
// ]
// }),
// 添加 需要 编译的目录
babelInclude([
// 当前项目
path.resolve(process.cwd(), 'src'),
// public 目录
path.resolve(path.dirname(process.cwd()), 'public', 'src')
]),
// 按需加载
fixBabelImports('import', {
libraryName: 'antd',
libraryDirectory: 'es',
style: true,
}),
addLessLoader({
javascriptEnabled: true,
// modifyVars: { '@primary-color': '#1DA57A' },
localIdentName: "leng-[local]-[hash:base64:5]"
}),
const getYarnWorkspaces = require('get-yarn-workspaces');
const { override, babelInclude } = require('customize-cra');
module.exports = override(
babelInclude(getYarnWorkspaces())
);
addWebpackAlias
} = 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')
})
)
module.exports = (config, env) => {
config = override(
enableEslintIgnore(),
...addBabelPlugins(
'babel-plugin-emotion',
'babel-plugin-preval',
'babel-plugin-transform-do-expressions'
),
addDecoratorsLegacy(),
babelInclude([resolveApp('src')])
)(config);
config.target = 'electron-renderer';
config = rewireReactHotLoader(config, env);
return config;
};
const eslintRuleOptions = config.module.rules.filter(
r => r.use && r.use.some(u => u.options && u.options.useEslintrc !== void 0)
)[0].use[0].options;
if(!Array.isArray(eslintRuleOptions.globals)) eslintRuleOptions.globals = [];
eslintRuleOptions.globals = [...eslintRuleOptions.globals, ...Object.keys(vars)];
return config;
};
module.exports = override(
removeModuleScopePlugin(),
registerGlobals({
__DEV__: (process.env.NODE_ENV === "development")
}),
babelInclude([
path.resolve("src"),
path.resolve(modulesPath, "react-native-elements"),
path.resolve(modulesPath, "react-native-ratings"),
path.resolve(modulesPath, "react-native-status-bar-height"),
path.resolve(modulesPath, "react-native-vector-icons"),
path.resolve(modulesPath, "react-native-safe-area-view"),
path.resolve(modulesPath, "react-navigation"),
path.resolve(modulesPath, "react-native-tab-view"),
path.resolve(modulesPath, "react-native-touchable-scale"),
path.resolve(modulesPath, "expo-linear-gradient"),
path.resolve(modulesPath, "@react-navigation", "native"),
path.resolve(modulesPath, "react-native-gesture-handler-web"),
]),
addBabelPlugins(
"@babel/plugin-proposal-class-properties",
),