IT/Webpack

[Webpack] build할 때 LICENSE.txt 생성되지 않게 하기

Tesseractjh 2022. 6. 16. 11:26

Webpack으로 빌드를 했을 때 이와 같이 LICENSE.txt 파일이 같이 생성되는 경우가 있다. terser-webpack-plugin 또는 clean-webpack-plugin 설정으로 LICENSE.txt 파일이 더 이상 생성되지 않도록 할 수 있다.

 

 

1. terser-webpack-plugin으로 해결하기

const TerserPlugin = require('terser-webpack-plugin');

module.exports = {

  optimization: {
    minimizer: [
      new TerserPlugin({ extractComments: false })
    ]
  }
  
};

 

2. clean-webpack-plugin으로 해결하기

const { CleanWebpackPlugin } = require('clean-webpack-plugin');

module.exports = {

  plugins: [
    new CleanWebpackPlugin({
      cleanAfterEveryBuildPatterns: ['**/*.LICENSE.txt'],
      protectWebpackAssets: false
    })
  ]
  
};

 

 

참고자료

https://stackoverflow.com/questions/64818489/webpack-omit-creation-of-license-txt-files

 

Webpack - omit creation of LICENSE.txt files

I'm using Webpack 5 and along with the bundle.js file a bundle.js.LICENSE.txt file is created which is not needed, because https://github.com/codepunkt/webpack-license-plugin is used for this task....

stackoverflow.com