Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getWebpackConfig(baseConfig, env) {
/* eslint-disable strict */
'use strict'
if (!sanityContext) {
throw new Error('Sanity context has not been set for Storybook!')
}
const wpConfig = Object.assign({}, sanityContext, {commonChunkPlugin: false})
const sanityWpConfig = sanityServer.getWebpackDevConfig(wpConfig)
const config = Object.assign({}, genDefaultConfig(baseConfig, env))
const context = Object.assign({}, sanityContext, {webpack})
config.plugins = config.plugins.concat(wpIntegration.getPlugins(context))
config.module.rules = (config.module.rules || []).concat(wpIntegration.getLoaders(context))
config.module.rules = config.module.rules.filter(skipCssLoader)
config.module.rules.unshift(sanityWpConfig.module.rules.find(isCssLoader))
const jsonLoaderAt = config.module.rules.findIndex(rule =>
(rule.loader || '').includes('json-loader')
)
const jsonHackLoader = {
test: /\.json$/,
resourceQuery: /sanityPart=/,
loader: require.resolve('./jsonHackLoader.js')
}