在不同目录中具有相同文件名的webpack摩卡问题

时间:2019-04-22 18:02:26

标签: javascript unit-testing webpack mocha

目录结构

test
   ├── a
   │   └── test_index.js
   |   └── test_basic.js
   └── b
       └── test_index.js

Webpack设置

entry: GlobEntry('./test/**/test_*.js', './test/mocha.js'),
output: {
   path: path.resolve(__dirname, 'mocha_tests')
}

结果

mocha_tests
      └── mocha.js
      └── test_basic.js
      └── test_index.js  <-- this comes from 'b' dir.

说明
从结果中可以看到,a目录中的test_index.js不存在或被b目录中的test_index.js覆盖。我在Use webpack with __dirname correctlywebpack-glob-entry进行了研究,但没有找到解决方案。

我尝试使用[id][hash]例如filename: '[name]_[hash}' + '.js',但这仍然只导致b目录中只有1个文件。

预期结果

mocha_tests
      └── mocha.js
      └── test_a_basic.js
      └── test_a_index.js
      └── test_b_index.js

任何帮助将不胜感激。谢谢。

0 个答案:

没有答案