2022-01-07 19:39:25 +00:00
|
|
|
/* global __dirname */
|
|
|
|
|
2018-08-07 21:47:50 +00:00
|
|
|
const path = require('path');
|
2019-03-18 17:54:51 +00:00
|
|
|
const packageDefinition = require('./package.json');
|
2018-08-07 21:47:50 +00:00
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
2019-03-18 17:54:51 +00:00
|
|
|
const webpack = require('webpack');
|
2021-12-30 00:18:48 +00:00
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
2018-08-07 21:47:50 +00:00
|
|
|
|
2022-02-15 01:15:21 +00:00
|
|
|
const {VueLoaderPlugin} = require('vue-loader');
|
2019-03-18 17:54:51 +00:00
|
|
|
const gitRevision = require('child_process')
|
|
|
|
.execSync('git rev-parse HEAD')
|
|
|
|
.toString().trim();
|
|
|
|
const gitBranch = require('child_process')
|
|
|
|
.execSync('git rev-parse --abbrev-ref HEAD')
|
|
|
|
.toString().trim();
|
2018-08-07 21:47:50 +00:00
|
|
|
|
2022-01-07 19:39:25 +00:00
|
|
|
/** @type {import('webpack').Configuration} */
|
|
|
|
const config = {
|
2018-08-07 21:47:50 +00:00
|
|
|
entry: {
|
|
|
|
openmct: './openmct.js',
|
2022-03-25 16:13:10 +00:00
|
|
|
generatorWorker: './example/generator/generatorWorker.js',
|
2021-07-30 22:23:02 +00:00
|
|
|
couchDBChangesFeed: './src/plugins/persistence/couch/CouchChangesFeed.js',
|
2021-12-16 00:13:41 +00:00
|
|
|
inMemorySearchWorker: './src/api/objects/InMemorySearchWorker.js',
|
2019-12-11 22:27:13 +00:00
|
|
|
espressoTheme: './src/plugins/themes/espresso-theme.scss',
|
|
|
|
snowTheme: './src/plugins/themes/snow-theme.scss',
|
|
|
|
maelstromTheme: './src/plugins/themes/maelstrom-theme.scss'
|
2018-08-07 21:47:50 +00:00
|
|
|
},
|
|
|
|
output: {
|
2021-07-30 22:23:02 +00:00
|
|
|
globalObject: "this",
|
2018-08-07 21:47:50 +00:00
|
|
|
filename: '[name].js',
|
|
|
|
library: '[name]',
|
2019-06-25 20:56:39 +00:00
|
|
|
libraryTarget: 'umd',
|
2021-12-30 00:18:48 +00:00
|
|
|
publicPath: '',
|
2022-01-07 19:39:25 +00:00
|
|
|
hashFunction: 'xxhash64',
|
2021-12-30 00:18:48 +00:00
|
|
|
clean: true
|
2018-08-07 21:47:50 +00:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2019-12-13 23:36:01 +00:00
|
|
|
"@": path.join(__dirname, "src"),
|
2018-08-07 21:47:50 +00:00
|
|
|
"legacyRegistry": path.join(__dirname, "src/legacyRegistry"),
|
2022-02-15 13:07:58 +00:00
|
|
|
"saveAs": "file-saver/src/FileSaver.js",
|
2018-08-07 21:47:50 +00:00
|
|
|
"csv": "comma-separated-values",
|
|
|
|
"EventEmitter": "eventemitter3",
|
|
|
|
"bourbon": "bourbon.scss",
|
2021-10-26 20:35:23 +00:00
|
|
|
"plotly-basic": "plotly.js-basic-dist",
|
|
|
|
"plotly-gl2d": "plotly.js-gl2d-dist",
|
2022-05-09 20:58:12 +00:00
|
|
|
"d3-scale": path.join(__dirname, "node_modules/d3-scale/dist/d3-scale.min.js"),
|
2019-06-14 20:33:15 +00:00
|
|
|
"printj": path.join(__dirname, "node_modules/printj/dist/printj.min.js"),
|
2019-11-28 00:04:52 +00:00
|
|
|
"styles": path.join(__dirname, "src/styles"),
|
|
|
|
"MCT": path.join(__dirname, "src/MCT"),
|
2020-06-17 20:58:25 +00:00
|
|
|
"testUtils": path.join(__dirname, "src/utils/testUtils.js"),
|
|
|
|
"objectUtils": path.join(__dirname, "src/api/objects/object-utils.js"),
|
|
|
|
"utils": path.join(__dirname, "src/utils")
|
2018-08-07 21:47:50 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
plugins: [
|
2019-03-18 17:54:51 +00:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
__OPENMCT_VERSION__: `'${packageDefinition.version}'`,
|
|
|
|
__OPENMCT_BUILD_DATE__: `'${new Date()}'`,
|
|
|
|
__OPENMCT_REVISION__: `'${gitRevision}'`,
|
2021-12-30 00:18:48 +00:00
|
|
|
__OPENMCT_BUILD_BRANCH__: `'${gitBranch}'`
|
2019-03-18 17:54:51 +00:00
|
|
|
}),
|
2018-08-07 21:47:50 +00:00
|
|
|
new VueLoaderPlugin(),
|
2021-12-30 00:18:48 +00:00
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: 'src/images/favicons',
|
|
|
|
to: 'favicons'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: './index.html',
|
|
|
|
transform: function (content) {
|
|
|
|
return content.toString().replace(/dist\//g, '');
|
|
|
|
}
|
2022-06-04 01:24:43 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
from: 'src/plugins/imagery/layers',
|
|
|
|
to: 'imagery'
|
2021-12-30 00:18:48 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}),
|
2018-08-07 21:47:50 +00:00
|
|
|
new MiniCssExtractPlugin({
|
2019-12-11 22:27:13 +00:00
|
|
|
filename: '[name].css',
|
|
|
|
chunkFilename: '[name].css'
|
2021-12-30 00:18:48 +00:00
|
|
|
})
|
2018-08-07 21:47:50 +00:00
|
|
|
],
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.(sc|sa|c)ss$/,
|
|
|
|
use: [
|
2019-12-11 22:27:13 +00:00
|
|
|
MiniCssExtractPlugin.loader,
|
2021-12-30 00:18:48 +00:00
|
|
|
{
|
|
|
|
loader: 'css-loader'
|
|
|
|
},
|
|
|
|
'resolve-url-loader',
|
|
|
|
'sass-loader'
|
2018-08-07 21:47:50 +00:00
|
|
|
]
|
|
|
|
},
|
2021-12-30 00:18:48 +00:00
|
|
|
{
|
|
|
|
test: /\.vue$/,
|
|
|
|
use: 'vue-loader'
|
|
|
|
},
|
2018-08-07 21:47:50 +00:00
|
|
|
{
|
|
|
|
test: /\.html$/,
|
2022-03-29 23:11:15 +00:00
|
|
|
type: 'asset/source'
|
2018-08-07 21:47:50 +00:00
|
|
|
},
|
|
|
|
{
|
2022-03-30 16:58:26 +00:00
|
|
|
test: /\.(jpg|jpeg|png|svg)$/,
|
|
|
|
type: 'asset/resource',
|
|
|
|
generator: {
|
|
|
|
filename: 'images/[name][ext]'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.ico$/,
|
|
|
|
type: 'asset/resource',
|
|
|
|
generator: {
|
|
|
|
filename: 'icons/[name][ext]'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(woff|woff2?|eot|ttf)$/,
|
|
|
|
type: 'asset/resource',
|
|
|
|
generator: {
|
|
|
|
filename: 'fonts/[name][ext]'
|
2018-08-07 21:47:50 +00:00
|
|
|
}
|
2021-06-02 14:04:40 +00:00
|
|
|
}
|
2018-08-07 21:47:50 +00:00
|
|
|
]
|
|
|
|
},
|
2021-12-30 01:39:07 +00:00
|
|
|
stats: 'errors-warnings'
|
2018-08-07 21:47:50 +00:00
|
|
|
};
|
2022-01-07 19:39:25 +00:00
|
|
|
|
2022-03-30 16:58:26 +00:00
|
|
|
// eslint-disable-next-line no-undef
|
2022-01-07 19:39:25 +00:00
|
|
|
module.exports = config;
|