How to add some banner to the trunks header, such as copy right? #26754
-
What version of Next.js are you using?11.0.1 What version of Node.js are you using?v14.5.0 What browser are you using?Chrome What operating system are you using?macOs How are you deploying your application?next build Describe the Bugnew webpack.BannerPlugin({
banner: '/** some text */'
}) But i run the command 'next build', the js and css trunks not see the copyright. I sure the reason cause by webpack5 and next11. Expected BehaviorCan you tell me how do this? To Reproduceconst { Compilation, sources } = require('webpack')
class BannerPlugin {
constructor(options) {
this.banner = options.banner
}
apply(compiler) {
compiler.hooks.compilation.tap('BannerPlugin', (compilation) => {
compilation.hooks.processAssets.tap(
{
name: 'BannerPlugin',
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
},
(assets) => {
Object.entries(assets).forEach(([pathname, source]) => {
compilation.updateAsset(
pathname,
new sources.RawSource(this.banner + source.source())
)
})
}
)
})
}
}
module.exports = BannerPlugin |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
/*!
*
* @name: xxx
* @author: x xx
* @date: Friday, June 25th, 2021, 12:43:14 PM
* @version: 0.0.1
* @license: xxx
* @copyright: @2021xxx. All Rights Reserved
*/ |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
if (pathname.indexOf('.json') > -1) return compilation.updateAsset( |
Beta Was this translation helpful? Give feedback.
if (pathname.indexOf('.json') > -1) return
compilation.updateAsset(
pathname,
new sources.RawSource(this.banner + source.source())
)