Skip to content

Commit

Permalink
chore: merge configs and fix pathing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ozyx committed Sep 10, 2024
1 parent dc7b6b1 commit 29df4e2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 36 deletions.
63 changes: 31 additions & 32 deletions .webpack/webpack.common.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const projectRootDir = fileURLToPath(new URL('../', import.meta.url));
console.error('PROJECT ROOT DIR', projectRootDir);

/** @type {import('webpack').Configuration} */
const commonConfig = {
context: __dirname,
context: projectRootDir,
performance: {
hints: false
},
entry: {
'openmct-yamcs': '../src/openmct-yamcs.js'
'openmct-yamcs': './src/openmct-yamcs.js'
},
module: {
rules: [
Expand All @@ -46,7 +47,7 @@ const commonConfig = {
output: {
globalObject: "this",
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
path: path.resolve(projectRootDir, 'dist'),
library: {
type: 'umd',
export: 'default',
Expand All @@ -56,35 +57,33 @@ const commonConfig = {
devServer: {
compress: true,
port: 9000,
static: [{
directory: path.join(__dirname, '../example'),
}, {
directory: path.join(__dirname, '../node_modules/openmct/dist'),
publicPath: '/dist',
}],
static: [
{
directory: path.resolve(projectRootDir, './example'),
},
{
directory: path.resolve(projectRootDir, './node_modules/openmct/dist'),
publicPath: '/node_modules/openmct/dist'
},
],
proxy: [
{
context: ['/yamcs-proxy/'],
target: "http://0.0.0.0:8090/",
secure: false,
changeOrigin: true,
pathRewrite: { '^/yamcs-proxy/': '' }
},
{
context: ['/yamcs-proxy-ws/'],
target: "ws://0.0.0.0:8090/api/websocket",
secure: false,
changeOrigin: true,
ws: true,
pathRewrite: { '^/yamcs-proxy-ws/': '' }
}
]
},
resolve: {
alias: {
openmct: path.resolve(__dirname, '../node_modules/openmct/dist/openmct.js')
}
}
{
context: ["/yamcs-proxy/"],
target: "http://0.0.0.0:8090/",
secure: false,
changeOrigin: true,
pathRewrite: { "^/yamcs-proxy/": "" },
},
{
context: ["/yamcs-proxy-ws/"],
target: "ws://0.0.0.0:8090/api/websocket",
secure: false,
changeOrigin: true,
ws: true,
pathRewrite: { "^/yamcs-proxy-ws/": "" },
},
],
}
};

export default commonConfig;
Expand Down
6 changes: 3 additions & 3 deletions .webpack/webpack.dev.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import { merge } from "webpack-merge";
import commonConfig from "./webpack.common.mjs";
import { fileURLToPath } from 'node:url';

// Replicate __dirname functionality for ES modules
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const projectRootDir = fileURLToPath(new URL('../', import.meta.url));

/** @type {import('webpack').Configuration} */
const devConfig = {
context: projectRootDir,
mode: 'development',
devtool: 'eval-source-map',
entry: {
'openmct-yamcs-example': '../example/index.js'
'openmct-yamcs-example': './example/index.js'
},
}
export default merge(commonConfig, devConfig);
5 changes: 4 additions & 1 deletion .webpack/webpack.prod.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@

import { merge } from 'webpack-merge';
import prod from './webpack.prod.mjs';
import { fileURLToPath } from 'node:url';

const projectRootDir = fileURLToPath(new URL('../', import.meta.url));

/** @type {import('webpack').Configuration} */
const prodTestConfig = {
context: projectRootDir,
entry: {
'openmct-yamcs-example': '../example/index.js'
'openmct-yamcs-example': './example/index.js'
},
}
export default merge(prod, prodTestConfig);

0 comments on commit 29df4e2

Please sign in to comment.