Skip to content

Commit

Permalink
fix(build): Exclude test files
Browse files Browse the repository at this point in the history
  • Loading branch information
Volker Rose committed Jan 21, 2019
1 parent 46ea7ab commit 3795dcd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ var conf = require("./config");
var webpack = require("webpack");
var merge = require("webpack-merge");

const testFilePattern = "\\.(test|spec)\\.?";

// custom babel target for each node version
function getBabelTarget(envConfig) {
var key = "AWS_LAMBDA_JS_RUNTIME";
Expand Down Expand Up @@ -70,7 +72,9 @@ function webpackConfig(dir, additionalConfig) {
rules: [
{
test: /\.(m?js|ts)?$/,
exclude: /(node_modules|bower_components)/,
exclude: new RegExp(
`(node_modules|bower_components|${testFilePattern})`
),
use: {
loader: "babel-loader",
options: babelOpts
Expand All @@ -95,7 +99,9 @@ function webpackConfig(dir, additionalConfig) {
fs.readdirSync(dirPath).forEach(function(file) {
if (file.match(/\.(m?js|ts)$/)) {
var name = file.replace(/\.(m?js|ts)$/, "");
webpackConfig.entry[name] = "./" + file;
if (!name.match(new RegExp(testFilePattern))) {
webpackConfig.entry[name] = "./" + file;
}
}
});
if (Object.keys(webpackConfig.entry) < 1) {
Expand Down

0 comments on commit 3795dcd

Please sign in to comment.