From 3da201c22df47d8e017d65128f19554d46331f2e Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Mon, 2 Apr 2018 12:25:18 -0600 Subject: [PATCH] allow plugin code from clients to be parsed by webpack --- webpack.config.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index d6f216d02..c6b3a770f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -22,6 +22,7 @@ require('dotenv').config(); const { plugins, pluginsPath, PluginManager } = require('./plugins'); const manager = new PluginManager(plugins); const targetPlugins = manager.section('targets').plugins; +const clientPlugins = manager.section('client').plugins; debug(`Using ${pluginsPath} as the plugin configuration path`); @@ -51,6 +52,19 @@ const TALK_WEBPACK_SOURCE_MAP = _.get( const devtool = TALK_WEBPACK_SOURCE_MAP === 'none' ? false : TALK_WEBPACK_SOURCE_MAP; +// Exclude everything from node_modules except for those that may be in a +// plugin folder inside the node_modules folder. +const exclude = { + and: [ + // Exclude everything inside node_modules.. + /node_modules/, + // But not those that contain plugins. + { + not: clientPlugins.map(({ name }) => new RegExp(`node_modules\/${name}`)), + }, + ], +}; + //============================================================================== // Base Webpack Config //============================================================================== @@ -73,7 +87,7 @@ const config = { }, { loader: 'babel-loader', - exclude: /node_modules/, + exclude, test: /\.js$/, query: { cacheDirectory: true, @@ -82,11 +96,11 @@ const config = { { loader: 'hjson-loader', test: /\.(json|yml)$/, - exclude: /node_modules/, + exclude, }, { loader: 'yaml-loader', - exclude: /node_modules/, + exclude, test: /\.yml$/, }, { @@ -118,7 +132,7 @@ const config = { }, { test: /\.(graphql|gql)$/, - exclude: /node_modules/, + exclude, loader: 'graphql-tag/loader', }, ],