next#WebpackConfigContext TypeScript Examples
The following examples show how to use
next#WebpackConfigContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: addWebpackConfig.ts From nextclade with MIT License | 6 votes |
export function addWebpackConfig(nextConfig: NextConfig, customWebpackConfig: CustomWebpackConfig) {
const webpack = (webpackConfig: Configuration, options: WebpackConfigContext) => {
const newConfig = customWebpackConfig(nextConfig, webpackConfig, options)
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(newConfig, options)
}
return newConfig
}
return { ...nextConfig, webpack }
}
Example #2
Source File: addWebpackPlugin.ts From nextclade with MIT License | 6 votes |
export function addWebpackPlugin(
nextConfig: NextConfig,
plugin: WebpackPluginInstance | WebpackPluginFunction | ((this: Compiler, compiler: Compiler) => void) | any,
) {
return addWebpackConfig(
nextConfig,
(nextConfig: NextConfig, webpackConfig: Configuration, { isServer }: WebpackConfigContext) => {
if (!isServer) {
if (webpackConfig?.plugins) {
webpackConfig.plugins.push(plugin)
} else {
return { plugins: [plugin] }
}
}
return webpackConfig
},
)
}