如何从运行中排除node_modules
?
我认为webpack-node-externals
意味着这项任务。这是我的webpack.test-config.js
:
const nodeExternals = require('webpack-node-externals');
const config = {};
// in order to ignore built-in modules like path, fs, etc.
config.target = 'node';
// in order to ignore all modules in node_modules folder
config.externals = [nodeExternals()];
config.output = {
// sourcemap support for IntelliJ/Webstorm
devtoolModuleFilenameTemplate: '[absolute-resource-path]',
devtoolFallbackModuleFilenameTemplate: '[absolute-resource-path]?[hash]'
};
// 'cheap-module-source-map' faster than 'source-map'
config.devtool = "source-map";
module.exports = config;
我从package.json
运行测试:
"test": "mocha-webpack --webpack-config webpack.config-test.js \"**/test/*.test.js\"",
答案 0 :(得分:0)
添加以下代码并查看注释以获取详细信息。 有关详细信息,请参阅此链 https://www.npmjs.com/package/webpack-node-externals
var nodeExternals = require('webpack-node-externals');
...
module.exports = {
...
target: 'node', // in order to ignore built-in modules like path, fs, etc.
externals: [nodeExternals()], // in order to ignore all modules in node_modules folder
...
};