Skip to content

Commit

Permalink
feat: 🎸 bundle vtkjs with viewport to reduce build issues (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
ladeirarodolfo authored and JamesAPetts committed Dec 12, 2019
1 parent 1f76d6d commit 6aa257e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -33,6 +34,7 @@ module.exports = (env, argv) => {
},
module: {
rules: [
...externalConfig.moduleRules,
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
Expand All @@ -59,7 +61,6 @@ module.exports = (env, argv) => {
},
externals: [
// :wave:
/\b(vtk.js)/,
// Used to build/load metadata
{
'cornerstone-core': {
Expand Down
52 changes: 52 additions & 0 deletions .webpack/webpack.external.config.js
Original file line number Diff line number Diff line change
@@ -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(),
};

0 comments on commit 6aa257e

Please sign in to comment.