Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add some banner to the trunks header, such as copy right? #26752

Closed
Caesar-APAX opened this issue Jun 30, 2021 · 2 comments
Closed

How to add some banner to the trunks header, such as copy right? #26752

Caesar-APAX opened this issue Jun 30, 2021 · 2 comments
Labels
bug Issue was opened via the bug report template.

Comments

@Caesar-APAX
Copy link

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 Bug

new 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 Behavior

Can you tell me how do this?

To Reproduce

const { 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
@Caesar-APAX Caesar-APAX added the bug Issue was opened via the bug report template. label Jun 30, 2021
@Caesar-APAX
Copy link
Author

/*!
 *
 *  @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 
 */

@Caesar-APAX
Copy link
Author

Build error occurred
SyntaxError: Unexpected token / in JSON at position 0
at JSON.parse ()

@vercel vercel locked and limited conversation to collaborators Jun 30, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

2 participants