-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document webpack-asset-manifest integration
Closes #45
- Loading branch information
Showing
6 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Integration with webpack-assets-manifest | ||
|
||
[webpack-assets-manifest](https://github.com/webdeveric/webpack-assets-manifest) | ||
has a somewhat | ||
[undocumented feature](https://github.com/webdeveric/webpack-assets-manifest/blob/9261b516209ece4311b77f200b78ff5dc945985f/src/WebpackAssetsManifest.js#L448-L449) | ||
where it will include the `integrity` value generated by this plugin | ||
(by webpack-subresource-integrity) when configured with `integrity: true`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('ok'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
var expect = require('expect'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var webpackVersion = Number( | ||
require('webpack/package.json').version.split('.')[0] | ||
); | ||
|
||
module.exports.skip = function skip() { | ||
// webpack-assets-manifest 3 requires Webpack 4 | ||
return webpackVersion < 4; | ||
}; | ||
|
||
module.exports.check = function check(stats) { | ||
var manifest = JSON.parse( | ||
fs.readFileSync(path.join(__dirname, 'dist/manifest.json'), 'utf-8') | ||
); | ||
expect(manifest['index.js'].integrity).toMatch(/sha384-.* sha512-.*/); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
var SriPlugin = require('webpack-subresource-integrity'); | ||
var WebpackAssetsManifest = require('webpack-assets-manifest'); | ||
|
||
module.exports = { | ||
entry: { | ||
index: './index.js' | ||
}, | ||
output: { | ||
crossOriginLoading: 'anonymous' | ||
}, | ||
plugins: [ | ||
new SriPlugin({ | ||
hashFuncNames: ['sha384', 'sha512'], | ||
enabled: true | ||
}), | ||
new WebpackAssetsManifest({ integrity: true }) | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters