2023-01-12 19:46:35 +00:00
|
|
|
/* global __dirname module */
|
|
|
|
|
|
|
|
/*
|
|
|
|
This is the OpenMCT common webpack file. It is imported by the other three webpack configurations:
|
|
|
|
- webpack.prod.js - the production configuration for OpenMCT (default)
|
|
|
|
- webpack.dev.js - the development configuration for OpenMCT
|
|
|
|
- webpack.coverage.js - imports webpack.dev.js and adds code coverage
|
|
|
|
There are separate npm scripts to use these configurations, though simply running `npm install`
|
|
|
|
will use the default production configuration.
|
|
|
|
*/
|
|
|
|
const path = require('path');
|
|
|
|
const packageDefinition = require('../package.json');
|
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
|
|
const webpack = require('webpack');
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
|
|
|
|
|
const { VueLoaderPlugin } = require('vue-loader');
|
|
|
|
let gitRevision = 'error-retrieving-revision';
|
|
|
|
let gitBranch = 'error-retrieving-branch';
|
|
|
|
|
|
|
|
try {
|
|
|
|
gitRevision = require('child_process').execSync('git rev-parse HEAD').toString().trim();
|
|
|
|
gitBranch = require('child_process')
|
|
|
|
.execSync('git rev-parse --abbrev-ref HEAD')
|
|
|
|
.toString()
|
|
|
|
.trim();
|
|
|
|
} catch (err) {
|
|
|
|
console.warn(err);
|
|
|
|
}
|
|
|
|
|
2023-01-17 16:05:34 +00:00
|
|
|
const projectRootDir = path.resolve(__dirname, '..');
|
|
|
|
|
2023-01-12 19:46:35 +00:00
|
|
|
/** @type {import('webpack').Configuration} */
|
|
|
|
const config = {
|
2023-01-17 16:05:34 +00:00
|
|
|
context: projectRootDir,
|
2023-01-12 19:46:35 +00:00
|
|
|
entry: {
|
|
|
|
openmct: './openmct.js',
|
|
|
|
generatorWorker: './example/generator/generatorWorker.js',
|
|
|
|
couchDBChangesFeed: './src/plugins/persistence/couch/CouchChangesFeed.js',
|
|
|
|
inMemorySearchWorker: './src/api/objects/InMemorySearchWorker.js',
|
|
|
|
espressoTheme: './src/plugins/themes/espresso-theme.scss',
|
|
|
|
snowTheme: './src/plugins/themes/snow-theme.scss'
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
globalObject: 'this',
|
|
|
|
filename: '[name].js',
|
2023-01-17 16:05:34 +00:00
|
|
|
path: path.resolve(projectRootDir, 'dist'),
|
2023-01-12 19:46:35 +00:00
|
|
|
library: 'openmct',
|
|
|
|
libraryTarget: 'umd',
|
|
|
|
publicPath: '',
|
|
|
|
hashFunction: 'xxhash64',
|
|
|
|
clean: true
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2023-01-17 16:05:34 +00:00
|
|
|
'@': path.join(projectRootDir, 'src'),
|
|
|
|
legacyRegistry: path.join(projectRootDir, 'src/legacyRegistry'),
|
2023-01-12 19:46:35 +00:00
|
|
|
saveAs: 'file-saver/src/FileSaver.js',
|
|
|
|
csv: 'comma-separated-values',
|
|
|
|
EventEmitter: 'eventemitter3',
|
|
|
|
bourbon: 'bourbon.scss',
|
|
|
|
'plotly-basic': 'plotly.js-basic-dist',
|
|
|
|
'plotly-gl2d': 'plotly.js-gl2d-dist',
|
|
|
|
'd3-scale': path.join(projectRootDir, 'node_modules/d3-scale/dist/d3-scale.min.js'),
|
|
|
|
printj: path.join(projectRootDir, 'node_modules/printj/dist/printj.min.js'),
|
2023-01-17 16:05:34 +00:00
|
|
|
styles: path.join(projectRootDir, 'src/styles'),
|
2023-01-12 19:46:35 +00:00
|
|
|
MCT: path.join(projectRootDir, 'src/MCT'),
|
|
|
|
testUtils: path.join(projectRootDir, 'src/utils/testUtils.js'),
|
2023-01-17 16:05:34 +00:00
|
|
|
objectUtils: path.join(projectRootDir, 'src/api/objects/object-utils.js'),
|
2023-07-19 18:22:23 +00:00
|
|
|
utils: path.join(projectRootDir, 'src/utils'),
|
|
|
|
vue: path.join(projectRootDir, 'node_modules/@vue/compat/dist/vue.esm-bundler.js'),
|
2023-05-18 21:54:46 +00:00
|
|
|
}
|
2023-01-12 19:46:35 +00:00
|
|
|
},
|
2023-01-17 16:05:34 +00:00
|
|
|
plugins: [
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
__OPENMCT_VERSION__: `'${packageDefinition.version}'`,
|
|
|
|
__OPENMCT_BUILD_DATE__: `'${new Date()}'`,
|
|
|
|
__OPENMCT_REVISION__: `'${gitRevision}'`,
|
|
|
|
__OPENMCT_BUILD_BRANCH__: `'${gitBranch}'`
|
2023-05-18 21:54:46 +00:00
|
|
|
}),
|
2023-01-17 16:05:34 +00:00
|
|
|
new VueLoaderPlugin(),
|
2023-01-12 19:46:35 +00:00
|
|
|
new CopyWebpackPlugin({
|
2023-01-17 16:05:34 +00:00
|
|
|
patterns: [
|
2023-05-18 21:54:46 +00:00
|
|
|
{
|
2023-01-17 16:05:34 +00:00
|
|
|
from: 'src/images/favicons',
|
2023-01-12 19:46:35 +00:00
|
|
|
to: 'favicons'
|
2023-05-18 21:54:46 +00:00
|
|
|
},
|
|
|
|
{
|
2023-01-17 16:05:34 +00:00
|
|
|
from: './index.html',
|
|
|
|
transform: function (content) {
|
|
|
|
return content.toString().replace(/dist\//g, '');
|
2023-05-18 21:54:46 +00:00
|
|
|
}
|
2023-01-12 19:46:35 +00:00
|
|
|
},
|
2023-05-18 21:54:46 +00:00
|
|
|
{
|
2023-01-17 16:05:34 +00:00
|
|
|
from: 'src/plugins/imagery/layers',
|
2023-01-12 19:46:35 +00:00
|
|
|
to: 'imagery'
|
|
|
|
}
|
2023-05-18 21:54:46 +00:00
|
|
|
]
|
2023-01-12 19:46:35 +00:00
|
|
|
}),
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: '[name].css',
|
|
|
|
chunkFilename: '[name].css'
|
|
|
|
})
|
|
|
|
],
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.(sc|sa|c)ss$/,
|
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
{
|
|
|
|
loader: 'css-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'resolve-url-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'sass-loader',
|
|
|
|
options: { sourceMap: true }
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2023-05-18 21:54:46 +00:00
|
|
|
{
|
2023-01-12 19:46:35 +00:00
|
|
|
test: /\.vue$/,
|
2023-07-19 18:22:23 +00:00
|
|
|
loader: 'vue-loader',
|
|
|
|
options: {
|
|
|
|
compilerOptions: {
|
|
|
|
whitespace: 'preserve',
|
|
|
|
compatConfig: {
|
|
|
|
MODE: 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-05-18 21:54:46 +00:00
|
|
|
},
|
|
|
|
{
|
2023-01-12 19:46:35 +00:00
|
|
|
test: /\.html$/,
|
|
|
|
type: 'asset/source'
|
2023-05-18 21:54:46 +00:00
|
|
|
},
|
|
|
|
{
|
2023-01-12 19:46:35 +00:00
|
|
|
test: /\.(jpg|jpeg|png|svg)$/,
|
|
|
|
type: 'asset/resource',
|
|
|
|
generator: {
|
|
|
|
filename: 'images/[name][ext]'
|
2023-05-18 21:54:46 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2023-01-12 19:46:35 +00:00
|
|
|
test: /\.ico$/,
|
|
|
|
type: 'asset/resource',
|
|
|
|
generator: {
|
|
|
|
filename: 'icons/[name][ext]'
|
2023-05-18 21:54:46 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2023-01-12 19:46:35 +00:00
|
|
|
test: /\.(woff|woff2?|eot|ttf)$/,
|
|
|
|
type: 'asset/resource',
|
|
|
|
generator: {
|
|
|
|
filename: 'fonts/[name][ext]'
|
2023-05-18 21:54:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2023-01-12 19:46:35 +00:00
|
|
|
stats: 'errors-warnings',
|
|
|
|
performance: {
|
|
|
|
// We should eventually consider chunking to decrease
|
|
|
|
// these values
|
2023-01-20 22:34:12 +00:00
|
|
|
maxEntrypointSize: 27000000,
|
|
|
|
maxAssetSize: 27000000
|
2023-01-12 19:46:35 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = config;
|