Webpack copies the NOTICE-js to the output folder and puts a header with url to the notice in every webpack file
This commit is contained in:
parent
363dcdbdee
commit
233e16799d
5 changed files with 82 additions and 5 deletions
29
NOTICE-js
29
NOTICE-js
|
@ -12296,6 +12296,35 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
** object-hash; version 2.0.3 -- https://github.com/puleos/object-hash
|
||||||
|
Copyright (c) 2014 object-hash contributors
|
||||||
|
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 object-hash contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
------
|
------
|
||||||
|
|
||||||
** v8-compile-cache; version 2.0.3 -- https://github.com/zertosh/v8-compile-cache#readme
|
** v8-compile-cache; version 2.0.3 -- https://github.com/zertosh/v8-compile-cache#readme
|
||||||
|
|
|
@ -1,7 +1,35 @@
|
||||||
const { environment } = require('@rails/webpacker')
|
const { environment, config } = require('@rails/webpacker')
|
||||||
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
||||||
|
const webpack = require('webpack');
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const erb = require('./loaders/erb')
|
const erb = require('./loaders/erb')
|
||||||
|
const fs = require('fs')
|
||||||
|
const hash = require('object-hash')
|
||||||
|
|
||||||
|
function getTerser() {
|
||||||
|
if(environment.config &&
|
||||||
|
environment.config.optimization &&
|
||||||
|
environment.config.optimization.minimizer &&
|
||||||
|
environment.config.optimization.minimizer instanceof Array &&
|
||||||
|
environment.config.optimization.minimizer.length === 1)
|
||||||
|
return environment.config.optimization.minimizer[0]
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function outputLicenseFile(file, outputDir) {
|
||||||
|
const contents = fs.readFileSync(file);
|
||||||
|
const name = path.basename(file) + "-" + hash(contents) + ".txt";
|
||||||
|
if (!fs.existsSync(outputDir)) {
|
||||||
|
fs.mkdirSync(outputDir, {recursive: true});
|
||||||
|
}
|
||||||
|
fs.copyFileSync(file, path.join(outputDir, name));
|
||||||
|
|
||||||
|
return name;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
environment.loaders.prepend('erb', erb)
|
environment.loaders.prepend('erb', erb)
|
||||||
environment.plugins.append(
|
environment.plugins.append(
|
||||||
|
@ -13,4 +41,21 @@ environment.plugins.append(
|
||||||
async: false,
|
async: false,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
environment.plugins.prepend("BannerPlugin", new webpack.BannerPlugin(
|
||||||
|
{banner: `@hlicense License information is available at ${config.publicPath}${outputLicenseFile('NOTICE-js', config.outputPath)}`,
|
||||||
|
entryOnly: false}))
|
||||||
|
|
||||||
|
|
||||||
|
const terser = getTerser()
|
||||||
|
if (terser) {
|
||||||
|
terser.options.terserOptions = terser.options.terserOptions || {}
|
||||||
|
terser.options.terserOptions.output = terser.options.terserOptions.output || {}
|
||||||
|
terser.options.terserOptions.output.comments = /@hlicense/i
|
||||||
|
|
||||||
|
// we don't want terser to print out license headers, we'll handle that ourselves
|
||||||
|
terser.options.extractComments = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = environment
|
module.exports = environment
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
|
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
|
||||||
|
|
||||||
const environment = require('./environment')
|
const environment = require('./environment')
|
||||||
const modifyTerserPlugin = require('./plugins/modifyTerserPlugin');
|
|
||||||
environment.splitChunks((config) => {
|
environment.splitChunks((config) => {
|
||||||
const excludeDonateButtonFromSplit = {
|
const excludeDonateButtonFromSplit = {
|
||||||
optimization:
|
optimization:
|
||||||
|
@ -21,7 +19,6 @@ environment.splitChunks((config) => {
|
||||||
return Object.assign({}, config, excludeDonateButtonFromSplit)
|
return Object.assign({}, config, excludeDonateButtonFromSplit)
|
||||||
})
|
})
|
||||||
|
|
||||||
// we don't want terser to print out license headers, we'll handle that ourselves
|
|
||||||
environment.config.optimization.minimizer[0].options.extractComments = false;
|
|
||||||
|
|
||||||
module.exports = environment.toWebpackConfig()
|
module.exports = environment.toWebpackConfig()
|
||||||
|
|
|
@ -72,6 +72,7 @@
|
||||||
"jsdom": "^11.10.0",
|
"jsdom": "^11.10.0",
|
||||||
"mini-css-extract-plugin": "^0.9.0",
|
"mini-css-extract-plugin": "^0.9.0",
|
||||||
"node-sass": "^4.12.0",
|
"node-sass": "^4.12.0",
|
||||||
|
"object-hash": "^2.0.3",
|
||||||
"phantomjs-prebuilt": "^2.1.16",
|
"phantomjs-prebuilt": "^2.1.16",
|
||||||
"react-test-renderer": "^16.13.1",
|
"react-test-renderer": "^16.13.1",
|
||||||
"resolve-url-loader": "^2.3.0",
|
"resolve-url-loader": "^2.3.0",
|
||||||
|
|
|
@ -11145,6 +11145,11 @@ object-copy@^0.1.0:
|
||||||
define-property "^0.2.5"
|
define-property "^0.2.5"
|
||||||
kind-of "^3.0.3"
|
kind-of "^3.0.3"
|
||||||
|
|
||||||
|
object-hash@^2.0.3:
|
||||||
|
version "2.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-2.0.3.tgz#d12db044e03cd2ca3d77c0570d87225b02e1e6ea"
|
||||||
|
integrity sha512-JPKn0GMu+Fa3zt3Bmr66JhokJU5BaNBIh4ZeTlaCBzrBsOeXzwcKKAK1tbLiPKgvwmPXsDvvLHoWh5Bm7ofIYg==
|
||||||
|
|
||||||
object-inspect@^1.7.0:
|
object-inspect@^1.7.0:
|
||||||
version "1.8.0"
|
version "1.8.0"
|
||||||
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.8.0.tgz#df807e5ecf53a609cc6bfe93eac3cc7be5b3a9d0"
|
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.8.0.tgz#df807e5ecf53a609cc6bfe93eac3cc7be5b3a9d0"
|
||||||
|
|
Loading…
Reference in a new issue