1

we have Nexjs 12 version in our application, I have searched about SRI implementation for Nextjs 12 version,then found this offical nextjs github link https://github.com/vercel/next.js/issues/1037. I have tried with SRI configuration as per disscussion in github but no furitful results.

in next.config.js file

const withOffline = require('next-offline');
const withPlugins = require('next-compose-plugins');
const CompressionPlugin = require('compression-webpack-plugin');
const SriPlugin = require('webpack-subresource-integrity')
let nextConfig = {};
const customConfig = {

webpack: (config,{ isServer, dev }) => {
         config.output.crossOriginLoading = 'anonymous'
         config.plugins.push(new SriPlugin({
         hashFuncNames: ['sha256', 'sha384'],
         enabled: true,
        }))

return config;
},
};
nextConfig = {
 ...customConfig,
};
module.exports = withPlugins(
[
    [withOffline, { scope: '/' }],
    [{ compress: true }],
 ],
nextConfig,
);

but am getting the sriplugin is not a constructor. please adivce me further what I made mistakes in configuration. Thanks in advance.

I have tried with webpack-subresource-integrity plugin configuration in nextjs 12 but getting error as sriplugin is not a contrucctor.

I am expecting that to resolve this SRI configuration issue and know about that next js 12 and 13 supports the SRI.

Sarada
  • 21
  • 1

1 Answers1

1

According to the documentation of the package, you should import it like that :

import { SubresourceIntegrityPlugin } from "webpack-subresource-integrity";
// or: const { SubresourceIntegrityPlugin } = require('webpack-subresource-integrity');