feat: MIT copyright notice on bundle

This commit is contained in:
arthurfiorette 2022-12-25 17:29:09 -03:00
parent 00fdff0158
commit f842c36b9d
No known key found for this signature in database
GPG Key ID: 9D190CD53C53C555
3 changed files with 29 additions and 3 deletions

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2021 - present Arthur Fiorette
Copyright (c) 2021-present Arthur Fiorette & 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

View File

@ -4,6 +4,10 @@
const path = require('path');
const TerserWebpackPlugin = require('terser-webpack-plugin');
const { DefinePlugin } = require('webpack');
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { version } = require('../package.json');
const COPYRIGHT = `// Axios Cache Interceptor v${version} MIT License Copyright (c) 2021-present Arthur Fiorette & Contributors\n`;
/** @type {(...args: string[]) => string} */
const root = (...p) => path.resolve(__dirname, '..', ...p);
@ -84,7 +88,29 @@ const config = ({
minimizer: [new TerserWebpackPlugin({ parallel: true })]
},
plugins: [new DefinePlugin({ __ACI_DEV__: devBuild })]
plugins: [
// Chooses the right environment
new DefinePlugin({ __ACI_DEV__: devBuild }),
// Add a banner to the top of each file
{
apply: (compiler) => {
compiler.hooks.emit.tapAsync('FileListPlugin', (comp, cb) => {
for (const chunk of comp.chunks) {
for (const filename of chunk.files) {
const assets = comp.assets[filename];
// @ts-expect-error - _value is not a public property
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
assets._value = COPYRIGHT + assets._value;
}
}
cb();
});
}
}
]
});
module.exports = [

View File

@ -33,7 +33,7 @@
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
"resolveJsonModule": false, /* Enable importing .json files */
"resolveJsonModule": true, /* Enable importing .json files */
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */