【问题标题】:How can I see a list of packages actually used for my application bundle?如何查看实际用于我的应用程序包的软件包列表?
【发布时间】:2019-03-18 01:42:35
【问题描述】:

我在摇树时遇到问题。似乎它对我的项目不太有效。有没有办法查看我的 webpacked 文件中实际使用的依赖项列表?

Webpack 配置:

entry: sourceEntryFile,
  mode: 'production', // for webpack 4
  target: 'node',
  output: {
    filename: '[name].js',
    path: outputPathFolder,
    libraryTarget: 'commonjs',
  },
  resolve: {
    extensions: ['.js', '.json'],
    modules: ['node_modules']
  },
  node: {
    __dirname: false,
  },
  externals: {
    'aws-sdk': 'aws-sdk'
  },
  plugins: (() => {
    const plugins = [
      new webpack.DefinePlugin({
        'global.GENTLY': false
      })
    ];
    // plugins.push(new WebpackBundleAnalyzer.BundleAnalyzerPlugin());
    return plugins;
  })()

【问题讨论】:

  • 通常使用 WebpackBundleAnalyzer。你有什么问题?
  • @estus 我觉得删除死代码没有应有的效率。 WebpackBundleAnalyzer 只显示使用的内容,对吗?

标签: node.js webpack tree-shaking


【解决方案1】:

npm ls 似乎是最接近的一个。结果显示当前项目正在使用哪些模块。

【讨论】:

    猜你喜欢
    • 2014-06-11
    • 1970-01-01
    • 2011-07-12
    • 2019-07-14
    • 2017-12-30
    • 2017-07-21
    • 2017-03-15
    • 2010-11-12
    • 2011-03-07
    相关资源
    最近更新 更多