From 6aa257eb329ed6e38bfdacec438eeeba19da24ec Mon Sep 17 00:00:00 2001 From: ladeirarodolfo <39910206+ladeirarodolfo@users.noreply.github.com> Date: Thu, 12 Dec 2019 11:50:40 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20bundle=20vtkjs=20with=20?= =?UTF-8?q?viewport=20to=20reduce=20build=20issues=20(#82)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .webpack/webpack.config.js | 3 +- .webpack/webpack.external.config.js | 52 +++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .webpack/webpack.external.config.js diff --git a/.webpack/webpack.config.js b/.webpack/webpack.config.js index a234d04d..f906a263 100644 --- a/.webpack/webpack.config.js +++ b/.webpack/webpack.config.js @@ -5,6 +5,7 @@ const autoprefixer = require('autoprefixer'); const BundleAnalyzerPlugin = require('webpack-bundle-analyzer') .BundleAnalyzerPlugin; const { CleanWebpackPlugin } = require('clean-webpack-plugin'); +const externalConfig = require('./webpack.external.config').default; const ENTRY_VTK_EXT = path.join(__dirname, './../src/index.js'); const SRC_PATH = path.join(__dirname, './../src'); @@ -33,6 +34,7 @@ module.exports = (env, argv) => { }, module: { rules: [ + ...externalConfig.moduleRules, { test: /\.(js|jsx)$/, exclude: /node_modules/, @@ -59,7 +61,6 @@ module.exports = (env, argv) => { }, externals: [ // :wave: - /\b(vtk.js)/, // Used to build/load metadata { 'cornerstone-core': { diff --git a/.webpack/webpack.external.config.js b/.webpack/webpack.external.config.js new file mode 100644 index 00000000..9c14718b --- /dev/null +++ b/.webpack/webpack.external.config.js @@ -0,0 +1,52 @@ +// Configurations to support some packages with any sort of missing bundle configuration + +// Configure vtk rules +function configureVtkRules() { + return [ + { + issuer: /vtk\.js\//, + test: /\.glsl$/i, + loader: 'shader-loader', + }, + { + issuer: /vtk\.js\//, + test: /\.css$/, + exclude: /\.module\.css$/, + use: [ + { loader: 'style-loader' }, + { loader: 'css-loader' }, + { loader: 'postcss-loader' }, + ], + }, + { + issuer: /vtk\.js\//, + test: /\.module\.css$/, + use: [ + { loader: 'style-loader' }, + { + loader: 'css-loader', + options: { + localIdentName: '[name]-[local]_[sha512:hash:base64:5]', + modules: true, + }, + }, + { loader: 'postcss-loader' }, + ], + }, + { + issuer: /vtk\.js\//, + test: /\.svg$/, + use: [{ loader: 'raw-loader' }], + }, + { + issuer: /vtk\.js\//, + test: /\.worker\.js$/, + use: [ + { loader: 'worker-loader', options: { inline: true, fallback: false } }, + ], + }, + ]; +} +exports.default = { + moduleRules: configureVtkRules(), +};