We have Next JS 12 version in our application, I have searched about SRI implementation for Next JS 12 version,then found this offical Next JS GitHub discussion link. I have tried with SRI configuration as per discussion in GitHub but no fruitful 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 advice me further what I made mistakes in configuration. Thanks in advance.
I have tried with webpack-subresource-integrity plugin configuration in Next JS 12 but getting error as sriplugin is not a constructor.
I am expecting that to resolve this SRI configuration issue and know about that Next JS 12 and 13 supports the SRI.
According to the documentation of the package, you should import it like that :