如何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\"",