diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 172a558b20957e6d6712c89b0cec4269f52db871..5687faabf262d7ebfc70e2b3d7b7d342146166d4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,11 +17,9 @@ jobs: node-version: 16 cache: 'npm' - name: install voyager dependencies - run: (cd source/voyager && npm ci) + run: (cd source/voyager && npm ci --legacy-peer-deps) - name: install ui dependencies run: npm ci && (cd source/ui && npm ci) - - name: build voyager - run: npm run build-voyager - name: build UI run: npm run build-ui build-server: diff --git a/Dockerfile b/Dockerfile index ea594cd470d0e952a9afdd1160c30ada37346d65..cc509f0cac7ea7db314fde3edc6b6f6a65a32702 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ COPY source/server/package*.json /app/source/server/ RUN (cd /app/source/server && npm ci) COPY source/voyager/package*.json /app/source/voyager/ -RUN (cd /app/source/voyager && npm ci) +RUN (cd /app/source/voyager && npm ci --legacy-peer-deps) COPY source/ui/package*.json /app/source/ui/ RUN (cd /app/source/ui && npm ci) @@ -21,9 +21,6 @@ RUN npm run build-server # outputs files in /app/source/server/dist COPY source/voyager /app/source/voyager -RUN npm run build-voyager -# files are automatically picked up by build-ui - COPY source/ui /app/source/ui RUN npm run build-ui # outputs files in /app/dist diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..10aac34131022ef45ac46edaa7e84a154713085e --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# eCorpus + +## Description + +This is the code repository for **eCorpus**, a content management system by the [eThesaurus](https://ethesaurus.holusion.com) consortium. + +## Installation + +Follow the [Quick Start Guide](https://ethesaurus.holusion.com/en/doc/tutorials/deployment.html). + +## Repository structure + +The repository uses recursive [submodules](https://git-scm.com/docs/gitsubmodules), because the upstream [DPO-Voyager](https://github.com/) uses them. + +It means some commands will need to be run with the `--recurse-submodules` flag, or you will need to run `git submodule update --init --recursive` after cloning the repository. + +eg: `git clone --recurse-submodules git@github.com:Holusion/eCorpus` + +Day-to-day operations can be simplified by configuring git (globally or for thsi repository) to always recurse by default : `git config submodule.recurse true`. + diff --git a/package.json b/package.json index 2542e067b9fa9357ca59b34c09fd32562c2701fc..f15f79bd7cdb6024581bbb5b9d3e594129185341 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,6 @@ "test": "echo \"Error: no test specified\" && exit 1", "build-ui": "cd source/ui && webpack --mode=production", "build-server": "tsc -b source/server", - "build-voyager": "cd source/voyager/source/client; webpack --mode=production --env=app=all", "watch": "cd source/server && HOT_RELOAD=1 NODE_ENV=development ROOT_DIR=\"../../\" nodemon -e ts,js -w . -w ../ui/webpack.config.js -x ts-node index.ts" }, "author": "Holusion <contact@holusion.com>", diff --git a/source/server/templates/explorer.hbs b/source/server/templates/explorer.hbs index 8455e2e16833b4af37b25e685bff40b6d13c35d9..c9d588bd75e36819965b63d6410d3dd1da83bcf1 100644 --- a/source/server/templates/explorer.hbs +++ b/source/server/templates/explorer.hbs @@ -1,3 +1,3 @@ <voyager-explorer resourceroot="/dist/" root="/scenes/{{scene}}/" referrer="{{referrer}}" lang="{{lang}}"></voyager-explorer> -<script type="text/javascript" src="/dist/js/voyager-explorer.min.js"></script> +<script type="text/javascript" src="/dist/js/voyager-explorer.js"></script> diff --git a/source/server/templates/story.hbs b/source/server/templates/story.hbs index 0368a21b8496fbaab1e649a1a47d220ae78e3899..bca3d94c14be2536575135d08a24cada8412e72d 100644 --- a/source/server/templates/story.hbs +++ b/source/server/templates/story.hbs @@ -1,4 +1,4 @@ <voyager-story resourceRoot="/dist/" root="/scenes/{{scene}}/" referrer="{{referrer}}" lang="{{lang}}" mode="{{mode}}"></voyager-story> -<script type="text/javascript" src="/dist/js/voyager-story.min.js"></script> -<link rel="stylesheet" href="/dist/css/voyager-story.min.css"> \ No newline at end of file +<script type="text/javascript" src="/dist/js/voyager-story.js"></script> +<link rel="stylesheet" href="/dist/css/voyager-story.css"> \ No newline at end of file diff --git a/source/ui/corpus.hbs b/source/ui/corpus.hbs deleted file mode 100644 index 9458c48b9aadc168f5ef0928a528be16d2806ace..0000000000000000000000000000000000000000 --- a/source/ui/corpus.hbs +++ /dev/null @@ -1,20 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>{{title}}</title> - - <link rel="shortcut icon" type="image/png" href="/static/favicon.png"/> - <style> - body{ - background: #303030; - } - </style> - - </head> - <body> - {{{element}}} - </body> -</html> \ No newline at end of file diff --git a/source/ui/story.hbs b/source/ui/story.hbs deleted file mode 100644 index 69ba1634874a0b828ab19b09655d5d268a6e9694..0000000000000000000000000000000000000000 --- a/source/ui/story.hbs +++ /dev/null @@ -1,33 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <title>{{title}}</title> - - <link rel="shortcut icon" type="image/png" href="/images/logo-ecorpus.png"/> - <link href="/fonts/fonts.css" rel="stylesheet"> - - <style> - body { background: #303030; } - </style> - - {{#if isDevelopment}} - <script src="/libs/three/three.js"></script> - {{else}} - <script src="/libs/three/three.min.js"></script> - {{/if}} - - <style> - /* overrides */ - .sv-asset-panel .sv-panel-header{ - display: none; - } - </style> - - </head> - <body> - {{{element}}} - </body> -</html> \ No newline at end of file diff --git a/source/ui/webpack.config.js b/source/ui/webpack.config.js index e1a38d82a6dff342abeaf95cfb8f8dfd9b5cab28..5ff83327456d97257b252e7910a02e9849fb8e2e 100644 --- a/source/ui/webpack.config.js +++ b/source/ui/webpack.config.js @@ -42,16 +42,16 @@ const dirs = { assets: path.resolve( project, "source/ui/assets"), }; +const createVoyagerConfig = require(path.join(project, "source/voyager/source/client/webpack.config.js")); //////////////////////////////////////////////////////////////////////////////// -module.exports = function createAppConfig(env, argv) +module.exports = function createAppConfig(env, argv={}) { const isDevMode = (typeof argv?.mode !== "undefined") ? argv.mode !== "production" : process.env["NODE_ENV"] !== "production"; const devMode = isDevMode ? "development" : "production"; - const config = { mode: devMode, cache: {type: "filesystem"}, @@ -64,7 +64,7 @@ module.exports = function createAppConfig(env, argv) filename: "js/[name].js", publicPath: '/', - clean: true, + clean: false, }, resolve: { @@ -98,7 +98,7 @@ module.exports = function createAppConfig(env, argv) }, { from: "{js,js/draco,css,language,images}/*.{js,json,wasm,css,jpg,png,svg}", - context: path.join(project, "source/voyager/dist/"), + context: path.join(project, "source/voyager/assets/"), force: false, priority: 1, }, @@ -161,5 +161,32 @@ module.exports = function createAppConfig(env, argv) config.devtool = "source-map"; } - return config; + const voyagerConfig = createVoyagerConfig({app: "all"}, argv); + /******************************** + * Override voyagerConfig's options + ********************************/ + + //Always use the same file name + Object.assign(voyagerConfig.output, { + path: dirs.output, + clean: false, + filename: "js/[name].js", + }); + + //Remove HTML exports + voyagerConfig.plugins = voyagerConfig.plugins.filter(p=>p.constructor?.name !="HtmlWebpackPlugin"); + //Remove Copy Plugin + voyagerConfig.plugins = voyagerConfig.plugins.filter(p=>p.constructor?.name !="CopyPlugin"); + + const cssPlugin = voyagerConfig.plugins.find(p=>p.constructor?.name =="MiniCssExtractPlugin"); + if(!cssPlugin) throw new Error("MiniCssExtractPlugin not found in voyagerConfig.plugins"); + Object.assign(cssPlugin.options, { + filename: "css/[name].css", + chunkFilename: "css/[name].css", + }); + + //Use filesystem cache for faster initial builds + Object.assign(voyagerConfig, {cache: {type: "filesystem"}}); + + return [config, voyagerConfig]; }