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

Function baseConfig

scripts/webpack.js:165–212  ·  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

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