Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
styleResource (ext) {
const { buildOptions: { styleResources }, options: { rootDir } } = this.buildContext
const extResource = styleResources[ext]
// style-resources-loader
// https://github.com/yenshih/style-resources-loader
if (!extResource) {
return
}
const patterns = wrapArray(extResource).map(p => path.resolve(rootDir, p))
return {
loader: 'style-resources-loader',
options: Object.assign(
{ patterns },
styleResources.options || {}
)
}
}
if (options.build.ssr) {
webpackConfigs.push(this.getWebpackConfig('Server'))
}
await this.buildContext.nuxt.callHook('webpack:config', webpackConfigs)
// Check styleResource existence
const { styleResources } = this.buildContext.options.build
if (styleResources && Object.keys(styleResources).length) {
consola.warn(
'Using styleResources without the @nuxtjs/style-resources is not suggested and can lead to severe performance issues.',
'Please use https://github.com/nuxt-community/style-resources-module'
)
for (const ext of Object.keys(styleResources)) {
await Promise.all(wrapArray(styleResources[ext]).map(async (p) => {
const styleResourceFiles = await glob(path.resolve(this.buildContext.options.rootDir, p))
if (!styleResourceFiles || styleResourceFiles.length === 0) {
throw new Error(`Style Resource not found: ${p}`)
}
}))
}
}
// Configure compilers
this.compilers = webpackConfigs.map((config) => {
const compiler = webpack(config)
// In dev, write files in memory FS
if (options.dev) {
compiler.outputFileSystem = this.mfs
normalize (loaders) {
loaders = wrapArray(loaders)
return loaders.map(loader => (typeof loader === 'string' ? { loader } : loader))
}