How to keep my shebang in place using webpack?

前端 未结 1 1073
萌比男神i
萌比男神i 2020-12-10 10:14

is there any way to make Webpack keep the #!/usr/bin/env node at the top of my file?

I\'m trying to bundle a CLI along with a module... it was a bit tri

相关标签:
1条回答
  • 2020-12-10 10:50

    You should be able to use BannerPlugin with raw mode for this. With this plugin you can add any string you want at the top of your bundle. By using the raw mode, it will not wrap the string in a comment.

    In your webpack.config.js file:

    plugins: [
        new webpack.BannerPlugin({ banner: "#!/usr/bin/env node", raw: true }),
    ]
    
    0 讨论(0)
提交回复
热议问题