Files
ohif-viewer/platform/viewer/.webpack/webpack.commonjs.js
T

50 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-10-11 14:26:24 -04:00
// ~~ WebPack
const webpack = require('webpack');
2019-08-13 15:36:46 -04:00
const path = require('path');
const merge = require('webpack-merge');
const webpackCommon = require('./../../../.webpack/webpack.commonjs.js');
2019-10-11 14:26:24 -04:00
// ~~ Plugins
2019-08-13 15:36:46 -04:00
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const fontsToJavaScriptRule = require('./rules/fontsToJavaScript.js');
2019-09-09 16:40:07 -04:00
const HtmlWebpackPlugin = require('html-webpack-plugin');
2019-08-13 15:36:46 -04:00
// const
const SRC_DIR = path.join(__dirname, '../src');
const DIST_DIR = path.join(__dirname, '../dist');
2019-09-09 16:40:07 -04:00
const PUBLIC_DIR = path.join(__dirname, '../public');
// ~~ Env Vars
const HTML_TEMPLATE = process.env.HTML_TEMPLATE || 'script-tag.html';
2019-08-13 15:36:46 -04:00
module.exports = (env, argv) => {
const commonConfig = webpackCommon(env, argv, { SRC_DIR, DIST_DIR });
2019-10-11 14:26:24 -04:00
const mergedConfig = merge(commonConfig, {
2019-08-13 15:36:46 -04:00
entry: {
2019-09-05 21:28:18 -04:00
app: `${SRC_DIR}/index-umd.js`,
2019-08-13 15:36:46 -04:00
},
output: {
path: DIST_DIR,
2019-09-09 15:50:45 -04:00
library: 'OHIFViewer',
2019-08-13 15:36:46 -04:00
libraryTarget: 'umd',
filename: 'index.umd.js',
},
module: {
rules: [fontsToJavaScriptRule],
2019-08-13 15:36:46 -04:00
},
plugins: [
// Clean output.path
new CleanWebpackPlugin(),
2019-09-09 16:40:07 -04:00
// Generate "index.html" w/ correct includes/imports
2019-10-11 14:26:24 -04:00
// NOTE: We use this for E2E Tests
2019-09-09 16:40:07 -04:00
new HtmlWebpackPlugin({
inject: false,
template: `${PUBLIC_DIR}/html-templates/${HTML_TEMPLATE}`,
filename: 'index.html',
}),
new webpack.optimize.LimitChunkCountPlugin({
2019-10-11 14:26:24 -04:00
maxChunks: 1,
}),
2019-08-13 15:36:46 -04:00
],
});
2019-10-11 14:26:24 -04:00
return mergedConfig;
2019-08-13 15:36:46 -04:00
};