Skip to content

Commit 8c5509e

Browse files
authored
Merge pull request #136 from waysact/134-electron-renderer-warning
Don't warn for electron-renderer target
2 parents ed3c8cd + b51b928 commit 8c5509e

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed

examples/electron-renderer/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Electron Renderer target
2+
3+
Ensure the plugin doesn't warn for electron-renderer targets.

examples/electron-renderer/index.js

Whitespace-only changes.

examples/electron-renderer/test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
};

jmtp.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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.'

0 commit comments

Comments
 (0)