split openmct dev/prod

This commit is contained in:
saji 2024-03-04 20:40:32 -06:00
parent 648f2183c2
commit a015911e0e
8 changed files with 66 additions and 24 deletions

17
web/jsconfig.json Normal file
View file

@ -0,0 +1,17 @@
{
"compilerOptions": {
// "baseUrl": "./src",
"target": "es6",
"checkJs": true,
"allowJs": true,
"moduleResolution": "nodenext",
"allowSyntheticDefaultImports": true,
"paths": {
"openmct": ["./node_modules/openmct/dist/openmct.d.ts"]
}
},
"exclude": [
"./dist/**/*",
"webpack.*.js"
]
}

3
web/package-lock.json generated
View file

@ -23,7 +23,8 @@
"typescript": "^4.9.5", "typescript": "^4.9.5",
"webpack": "^5.75.0", "webpack": "^5.75.0",
"webpack-cli": "^5.0.1", "webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.11.1" "webpack-dev-server": "^4.11.1",
"webpack-merge": "^5.10.0"
} }
}, },
"node_modules/@aashutoshrathi/word-wrap": { "node_modules/@aashutoshrathi/word-wrap": {

View file

@ -5,8 +5,8 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack", "build": "webpack --config webpack.prod.js",
"serve": "webpack serve" "serve": "webpack serve --config webpack.dev.js"
}, },
"author": "", "author": "",
"license": "ISC", "license": "ISC",
@ -25,6 +25,7 @@
"typescript": "^4.9.5", "typescript": "^4.9.5",
"webpack": "^5.75.0", "webpack": "^5.75.0",
"webpack-cli": "^5.0.1", "webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.11.1" "webpack-dev-server": "^4.11.1",
"webpack-merge": "^5.10.0"
} }
} }

View file

@ -7,6 +7,13 @@ openmct.install(openmct.plugins.UTCTimeSystem());
openmct.time.clock('local', {start: -5 * 60 * 1000, end: 0}); openmct.time.clock('local', {start: -5 * 60 * 1000, end: 0});
openmct.time.timeSystem('utc'); openmct.time.timeSystem('utc');
openmct.install(openmct.plugins.Espresso()); openmct.install(openmct.plugins.Espresso());
openmct.install(PhoebusPlugin());
if (process.env.BASE_URL) {
console.log("got a thing")
console.log(process.env.BASE_URL)
}
function GotelemPlugin() {
}
openmct.start(); openmct.start();

View file

@ -1,11 +0,0 @@
{
"compilerOptions": {
"baseUrl": "./src",
"target": "es6",
"checkJs": true,
"moduleResolution": "node",
"paths": {
"openmct": ["node_modules/openmct/dist/openmct.d.ts"]
}
}
}

View file

@ -5,7 +5,6 @@ const Dotenv = require('dotenv-webpack');
module.exports = { module.exports = {
entry: './src/app.js', entry: './src/app.js',
mode: "development",
module: { module: {
rules: [ rules: [
{ {
@ -33,13 +32,6 @@ module.exports = {
externals: { externals: {
openmct: "openmct", openmct: "openmct",
}, },
devServer: {
static: [{
// eslint-disable-next-line no-undef
directory: path.join(__dirname, '/node_modules/openmct/dist'),
publicPath: '/node_modules/openmct/dist'
}]
},
output: { output: {
filename: 'main.js', filename: 'main.js',
path: path.resolve(__dirname, 'dist'), path: path.resolve(__dirname, 'dist'),

22
web/webpack.dev.js Normal file
View file

@ -0,0 +1,22 @@
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
const webpack = require('webpack');
module.exports = merge(common, {
mode: "development",
devtool: 'inline-source-map',
plugins: [
new webpack.EnvironmentPlugin({
NODE_ENV: "development",
BASE_URL: "http://localhost:8080"
}),
],
devServer: {
static: "./dist",
headers: {
"Access-Control-Allow-Origin": "*",
'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Methods': '*',
},
},
})

13
web/webpack.prod.js Normal file
View file

@ -0,0 +1,13 @@
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: "production",
plugins: [
new webpack.EnvironmentPlugin({
NODE_ENV: "production",
BASE_URL: "",
});
],
devtool: 'source-map',
})