File tree Expand file tree Collapse file tree 5 files changed +42
-1
lines changed
examples/electron-renderer Expand file tree Collapse file tree 5 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 1+ # Electron Renderer target
2+
3+ Ensure the plugin doesn't warn for electron-renderer targets.
Original file line number Diff line number Diff line change 1+ var expect = require ( 'expect' ) ;
2+ var webpackVersion = Number (
3+ require ( 'webpack/package.json' ) . version . split ( '.' ) [ 0 ]
4+ ) ;
5+
6+ module . exports . skip = function skip ( ) {
7+ return webpackVersion < 5 ;
8+ } ;
9+
10+ module . exports . check = function check ( stats ) {
11+ expect ( stats . compilation . errors ) . toEqual ( [ ] ) ;
12+ expect ( stats . compilation . warnings ) . toEqual ( [ ] ) ;
13+ } ;
Original file line number Diff line number Diff line change 1+ var SriPlugin = require ( 'webpack-subresource-integrity' ) ;
2+ var HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
3+
4+ module . exports = {
5+ entry : {
6+ index : './index.js'
7+ } ,
8+ target : 'electron-renderer' ,
9+ output : {
10+ crossOriginLoading : 'anonymous'
11+ } ,
12+ plugins : [
13+ new SriPlugin ( {
14+ hashFuncNames : [ 'sha256' , 'sha384' ] ,
15+ enabled : true
16+ } ) ,
17+ new HtmlWebpackPlugin ( )
18+ ]
19+ } ;
Original file line number Diff line number Diff line change @@ -76,7 +76,13 @@ WebIntegrityJsonpMainTemplatePlugin.prototype.apply = function apply(
7676 var linkPreloadPlugin = this . addAttribute . bind ( this , mainTemplate , "link" ) ;
7777 var addSriHashes = this . addSriHashes . bind ( this , mainTemplate ) ;
7878
79- if ( this . compilation . compiler . options . target !== 'web' ) {
79+ if (
80+ this . compilation . outputOptions . chunkLoading
81+ ? [ 'require' , 'async-node' ] . includes (
82+ this . compilation . outputOptions . chunkLoading
83+ )
84+ : this . compilation . compiler . options . target !== 'web'
85+ ) {
8086 this . sriPlugin . warnOnce (
8187 this . compilation ,
8288 'This plugin is not useful for non-web targets.'
You can’t perform that action at this time.
0 commit comments