forked from OHIF/react-vtkjs-viewport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.js
115 lines (111 loc) · 2.92 KB
/
webpack.dev.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/**
* vtkRules contains three rules:
*
* - shader-loader
* - babel-loader
* - worker-loader
*
* The defaults work fine for us here, but it's worth noting that for a UMD build,
* we would like likely want to inline web workers. An application consuming this package
* will likely want to use a non-default loader option:
*
* {
* test: /\.worker\.js$/,
* include: /vtk\.js[\/\\]Sources/,
* use: [
* {
* loader: 'worker-loader',
* options: { inline: true, fallback: false },
* },
* ],
* },
*/
const path = require('path');
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
const vtkRules = require('vtk.js/Utilities/config/dependency.js').webpack.core
.rules;
// Plugins
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ENTRY_VTK_EXT = path.join(__dirname, './../src/index.js');
const ENTRY_EXAMPLES = path.join(__dirname, './../examples/index.js');
const SRC_PATH = path.join(__dirname, './../src');
const OUT_PATH = path.join(__dirname, './../dist');
// Add this additional call so we can yarn link vtk.js
// const shaderLoader = {
// test: /\.glsl$/i,
// loader: 'shader-loader',
// };
module.exports = {
entry: {
examples: ENTRY_EXAMPLES,
},
devtool: 'source-map',
output: {
path: OUT_PATH,
filename: '[name].bundle.[hash].js',
library: 'ReactVTKjsViewport',
libraryTarget: 'umd',
globalObject: 'this',
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
{
test: /\.css$/,
exclude: /\.module\.css$/,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: () => [autoprefixer('last 2 version', 'ie >= 10')],
},
},
],
},
].concat(vtkRules),
//.concat(shaderLoader),
},
resolve: {
modules: [path.resolve(__dirname, './../node_modules'), SRC_PATH],
alias: {
'@vtk-viewport': ENTRY_VTK_EXT,
},
},
plugins: [
// Show build progress
new webpack.ProgressPlugin(),
// Clear dist between builds
new CleanWebpackPlugin(),
// Generate `index.html` with injected build assets
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.resolve(__dirname, '..', 'public', 'index.html'),
}),
// Copy "Public" Folder to Dist (test data)
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '..', 'public'),
to: OUT_PATH,
toType: 'dir',
ignore: ['index.html', '.DS_Store'],
},
]),
],
// Fix for `cornerstone-wado-image-loader` fs dep
node: { fs: 'empty' },
devServer: {
hot: true,
open: true,
port: 3000,
historyApiFallback: true,
},
};