Skip to content
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

Build output files overwritten by Terser Plugin if comments extract enabled #148

Closed
njugray opened this issue Feb 27, 2019 · 6 comments
Closed

Comments

@njugray
Copy link
Contributor

njugray commented Feb 27, 2019

filename: '[name].js?[hash]',

If comments extract enabled,comments will be extracted to separated files with suffix . LICENSE

With the default configuration of Beidou, which will leads to [name].js?[hash].LICENSE, reference to the same file, may cause source files overwritten by LICENSE files.

@justquanyin
Copy link
Collaborator

justquanyin commented Feb 27, 2019

这个问题遇到过,开始的考虑是保留LICENSE的文件输出,但用户可以选择上传的文件中过滤掉LICENSE,既然有争议,可以去掉这个配置
https://github.com/alibaba/beidou/blob/master/packages/beidou-webpack/config/webpack/webpack.browser.js#L70
我默认去掉吧

@ahungrynoob
Copy link
Contributor

[name]-[hash].js可以吗

@njugray
Copy link
Contributor Author

njugray commented Feb 27, 2019

[name]-[hash].js 的形式,文件不好引用

@ahungrynoob
Copy link
Contributor

@njugray

module.exports = {
  assetWithHash(asset) {
    // 读取配置中的manifest
    const manifest = this.app.config.manifest || {};
    // 映射文件名
    let filename = asset;
    if (manifest[asset]) {
      filename = manifest[asset];
      return filename;
    }
    return this.helper.asset(filename);
  },
};

感觉利用ManifestPlugin

const ManifestPlugin = require('webpack-manifest-plugin');
factory.addPlugin(ManifestPlugin, { fileName: '../manifest.json' }, 'WebpackManifestPlugin');

顺便解决 #55

@njugray
Copy link
Contributor Author

njugray commented Feb 27, 2019

@ahungrynoob 这个可以作为新feature开发,当前这是个bug,先默认关闭 extractComments 修复掉

@ahungrynoob
Copy link
Contributor

哦哦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants