From 5753756040e4a903d3eb88f6e27ea5887776507a Mon Sep 17 00:00:00 2001 From: "Peter A. Jonsson" Date: Tue, 25 Mar 2025 01:35:54 +0100 Subject: [PATCH] webpack: parameterize build sources Add a new parameter that is a list of paths that are included in the js/ts rule for building, and pass in the test directory through that path. This allows TerriaMap to avoid building the test sources, which means it no longer requires TerriaJS's devDependencies to be installed. --- buildprocess/configureWebpack.js | 6 ++++-- buildprocess/webpack-tools.config.js | 5 ++++- buildprocess/webpack.config.make.js | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/buildprocess/configureWebpack.js b/buildprocess/configureWebpack.js index d51935f31fc..89633d0bf1d 100644 --- a/buildprocess/configureWebpack.js +++ b/buildprocess/configureWebpack.js @@ -8,6 +8,7 @@ const webpack = require("webpack"); * Supplements the given webpack config with options required to build TerriaJS * * @param [options.terriaJSBasePath] The TerriaJS source directory + * @param [options.jsExtraPaths] Additional include paths for js/ts files. * @param [options.config] Base webpack configuration * @param [options.devMode] Set to `true` to generate for development build, default is `false`. * @param [options.MiniCssExtractPlugin] @@ -15,6 +16,7 @@ const webpack = require("webpack"); */ function configureWebpack({ terriaJSBasePath, + jsExtraPaths, config, devMode, MiniCssExtractPlugin, @@ -64,10 +66,10 @@ function configureWebpack({ include: [ path.resolve(terriaJSBasePath, "node_modules", "commander"), path.resolve(terriaJSBasePath, "lib"), - path.resolve(terriaJSBasePath, "test"), path.resolve(terriaJSBasePath, "buildprocess", "generateDocs.ts"), path.resolve(terriaJSBasePath, "buildprocess", "generateCatalogIndex.ts"), - path.resolve(terriaJSBasePath, "buildprocess", "patchNetworkRequests.ts") + path.resolve(terriaJSBasePath, "buildprocess", "patchNetworkRequests.ts"), + ...jsExtraPaths ], use: [babelLoader] }); diff --git a/buildprocess/webpack-tools.config.js b/buildprocess/webpack-tools.config.js index 2c78229ad9c..82586263678 100644 --- a/buildprocess/webpack-tools.config.js +++ b/buildprocess/webpack-tools.config.js @@ -59,8 +59,11 @@ module.exports = function () { } }; + const terriaJSBasePath = path.dirname(require.resolve("../package.json")); + const jsExtraPaths = [path.resolve(terriaJSBasePath, "test")]; return configureWebpackForTerriaJS({ - terriaJSBasePath: path.dirname(require.resolve("../package.json")), + terriaJSBasePath, + jsExtraPaths, config, devMode, MiniCssExtractPlugin, diff --git a/buildprocess/webpack.config.make.js b/buildprocess/webpack.config.make.js index 20eb7787d75..906e0232113 100644 --- a/buildprocess/webpack.config.make.js +++ b/buildprocess/webpack.config.make.js @@ -63,8 +63,10 @@ module.exports = function (devMode) { } }; + const jsExtraPaths = [path.resolve(terriaJSBasePath, "test")]; return configureWebpack({ terriaJSBasePath, + jsExtraPaths, config, devMode, MiniCssExtractPlugin