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(
76
76
var linkPreloadPlugin = this . addAttribute . bind ( this , mainTemplate , "link" ) ;
77
77
var addSriHashes = this . addSriHashes . bind ( this , mainTemplate ) ;
78
78
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
+ ) {
80
86
this . sriPlugin . warnOnce (
81
87
this . compilation ,
82
88
'This plugin is not useful for non-web targets.'
You can’t perform that action at this time.
0 commit comments