MCPcopy Create free account
hub / github.com/decaporg/decap-cms / baseConfig

Function baseConfig

scripts/webpack.js:177–224  ·  view source on GitHub ↗

* Use [getConfig({ target:'umd' }), getConfig({ target:'cjs' })] for * getting multiple configs and add the new output in targetOutputs if needed. * Default: umd

({ target = isProduction ? 'umd' : 'umddir' } = {})

Source from the content-addressed store, hash-verified

175 * Default: umd
176 */
177function baseConfig({ target = isProduction ? 'umd' : 'umddir' } = {}) {
178 return {
179 context: process.cwd(),
180 mode: isProduction ? 'production' : 'development',
181 entry: './src',
182 output: targetOutputs()[target],
183 module: {
184 rules: flatMap(Object.values(rules()), rule => rule()),
185 },
186 resolve: {
187 extensions: ['.ts', '.tsx', '.js', '.json'],
188 fallback: {
189 stream: require.resolve('stream-browserify'),
190 url: require.resolve('url/'),
191 process: require.resolve('process/browser'),
192 },
193 alias: {
194 url: require.resolve('url/'),
195 'process/browser': require.resolve('process/browser'),
196 // Polyfill for fileURLToPath used by clean-stack
197 'node:url': require.resolve('url/'),
198 ...reactDomServerAlias(),
199 'react-style-proptype$': path.resolve(__dirname, 'shims/noopPropType.js'),
200 'js-yaml$': path.resolve(__dirname, 'shims/unusedJsYaml.js'),
201 },
202 },
203 plugins: Object.values(plugins()).map(plugin => plugin()),
204 devtool: isTest ? '' : 'source-map',
205 target: 'web',
206
207 /**
208 * Exclude peer dependencies from package bundles.
209 */
210 externals:
211 target.slice(0, 3) === 'umd'
212 ? umdExternals
213 : (context, request, cb) => {
214 const externals = Object.keys(pkg.peerDependencies || {});
215
216 function isPeerDep(dep) {
217 return new RegExp(`^${dep}($|/)`).test(request);
218 }
219
220 return externals.some(isPeerDep) ? cb(null, request) : cb();
221 },
222 stats: stats(),
223 };
224}
225
226function getConfig({ baseOnly = false } = {}) {
227 if (baseOnly) {

Callers 1

getConfigFunction · 0.85

Calls 8

targetOutputsFunction · 0.85
rulesFunction · 0.85
reactDomServerAliasFunction · 0.85
statsFunction · 0.85
resolveMethod · 0.80
mapMethod · 0.80
someMethod · 0.80
pluginsFunction · 0.70

Tested by

no test coverage detected