2022-01-07 11:39:25 -08:00
|
|
|
/* global __dirname */
|
|
|
|
|
2018-08-07 14:47:50 -07:00
|
|
|
const path = require('path');
|
2019-03-18 10:54:51 -07:00
|
|
|
const packageDefinition = require('./package.json');
|
2018-08-07 14:47:50 -07:00
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
2019-03-18 10:54:51 -07:00
|
|
|
const webpack = require('webpack');
|
2021-12-29 16:18:48 -08:00
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
2018-08-07 14:47:50 -07:00
|
|
|
|
2022-02-14 17:15:21 -08:00
|
|
|
const {VueLoaderPlugin} = require('vue-loader');
|
2019-03-18 10:54:51 -07: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 14:47:50 -07:00
|
|
|
|
2022-01-07 11:39:25 -08:00
|
|
|
/** @type {import('webpack').Configuration} */
|
|
|
|
const config = {
|
2018-08-07 14:47:50 -07:00
|
|
|
entry: {
|
|
|
|
openmct: './openmct.js',
|
2022-03-25 17:13:10 +01:00
|
|
|
generatorWorker: './example/generator/generatorWorker.js',
|
2021-07-30 15:23:02 -07:00
|
|
|
couchDBChangesFeed: './src/plugins/persistence/couch/CouchChangesFeed.js',
|
2021-12-16 01:13:41 +01:00
|
|
|
inMemorySearchWorker: './src/api/objects/InMemorySearchWorker.js',
|
2019-12-11 14:27:13 -08: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 14:47:50 -07:00
|
|
|
},
|
|
|
|
output: {
|
2021-07-30 15:23:02 -07:00
|
|
|
globalObject: "this",
|
2018-08-07 14:47:50 -07:00
|
|
|
filename: '[name].js',
|
|
|
|
library: '[name]',
|
2019-06-25 13:56:39 -07:00
|
|
|
libraryTarget: 'umd',
|
2021-12-29 16:18:48 -08:00
|
|
|
publicPath: '',
|
2022-01-07 11:39:25 -08:00
|
|
|
hashFunction: 'xxhash64',
|
2021-12-29 16:18:48 -08:00
|
|
|
clean: true
|
2018-08-07 14:47:50 -07:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2019-12-13 15:36:01 -08:00
|
|
|
"@": path.join(__dirname, "src"),
|
2018-08-07 14:47:50 -07:00
|
|
|
"legacyRegistry": path.join(__dirname, "src/legacyRegistry"),
|
2022-02-15 14:07:58 +01:00
|
|
|
"saveAs": "file-saver/src/FileSaver.js",
|
2018-08-07 14:47:50 -07:00
|
|
|
"csv": "comma-separated-values",
|
|
|
|
"EventEmitter": "eventemitter3",
|
|
|
|
"bourbon": "bourbon.scss",
|
2021-10-26 13:35:23 -07: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 13:33:15 -07:00
|
|
|
"printj": path.join(__dirname, "node_modules/printj/dist/printj.min.js"),
|
2019-11-27 16:04:52 -08:00
|
|
|
"styles": path.join(__dirname, "src/styles"),
|
|
|
|
"MCT": path.join(__dirname, "src/MCT"),
|
2020-06-17 13:58:25 -07: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 14:47:50 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
plugins: [
|
2019-03-18 10:54:51 -07:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
__OPENMCT_VERSION__: `'${packageDefinition.version}'`,
|
|
|
|
__OPENMCT_BUILD_DATE__: `'${new Date()}'`,
|
|
|
|
__OPENMCT_REVISION__: `'${gitRevision}'`,
|
2021-12-29 16:18:48 -08:00
|
|
|
__OPENMCT_BUILD_BRANCH__: `'${gitBranch}'`
|
2019-03-18 10:54:51 -07:00
|
|
|
}),
|
2018-08-07 14:47:50 -07:00
|
|
|
new VueLoaderPlugin(),
|
2021-12-29 16:18:48 -08:00
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: 'src/images/favicons',
|
|
|
|
to: 'favicons'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: './index.html',
|
|
|
|
transform: function (content) {
|
|
|
|
return content.toString().replace(/dist\//g, '');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}),
|
2018-08-07 14:47:50 -07:00
|
|
|
new MiniCssExtractPlugin({
|
2019-12-11 14:27:13 -08:00
|
|
|
filename: '[name].css',
|
|
|
|
chunkFilename: '[name].css'
|
2021-12-29 16:18:48 -08:00
|
|
|
})
|
2018-08-07 14:47:50 -07:00
|
|
|
],
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.(sc|sa|c)ss$/,
|
|
|
|
use: [
|
2019-12-11 14:27:13 -08:00
|
|
|
MiniCssExtractPlugin.loader,
|
2021-12-29 16:18:48 -08:00
|
|
|
{
|
|
|
|
loader: 'css-loader'
|
|
|
|
},
|
|
|
|
'resolve-url-loader',
|
|
|
|
'sass-loader'
|
2018-08-07 14:47:50 -07:00
|
|
|
]
|
|
|
|
},
|
2021-12-29 16:18:48 -08:00
|
|
|
{
|
|
|
|
test: /\.vue$/,
|
|
|
|
use: 'vue-loader'
|
|
|
|
},
|
2018-08-07 14:47:50 -07:00
|
|
|
{
|
|
|
|
test: /\.html$/,
|
2022-03-29 23:11:15 +00:00
|
|
|
type: 'asset/source'
|
2018-08-07 14:47:50 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /zepto/,
|
|
|
|
use: [
|
|
|
|
"imports-loader?this=>window",
|
|
|
|
"exports-loader?Zepto"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
2022-03-30 18:58:26 +02: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 14:47:50 -07:00
|
|
|
}
|
2021-06-02 07:04:40 -07:00
|
|
|
}
|
2018-08-07 14:47:50 -07:00
|
|
|
]
|
|
|
|
},
|
2021-12-29 17:39:07 -08:00
|
|
|
stats: 'errors-warnings'
|
2018-08-07 14:47:50 -07:00
|
|
|
};
|
2022-01-07 11:39:25 -08:00
|
|
|
|
2022-03-30 18:58:26 +02:00
|
|
|
// eslint-disable-next-line no-undef
|
2022-01-07 11:39:25 -08:00
|
|
|
module.exports = config;
|