Skip to content

Commit

Permalink
speed up build process by importing voyager build script into source/ui
Browse files Browse the repository at this point in the history
  • Loading branch information
sdumetz committed Jan 8, 2024
1 parent 0207f0d commit 8511549
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 61 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# eCorpus

## Description

This is the code repository for **eCorpus**, a content management system by the [eThesaurus](https://ethesaurus.holusion.com) consortium.

## 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 [email protected]: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`.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion source/server/templates/explorer.hbs
Original file line number Diff line number Diff line change
@@ -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>
4 changes: 2 additions & 2 deletions source/server/templates/story.hbs
Original file line number Diff line number Diff line change
@@ -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">
<script type="text/javascript" src="/dist/js/voyager-story.js"></script>
<link rel="stylesheet" href="/dist/css/voyager-story.css">
20 changes: 0 additions & 20 deletions source/ui/corpus.hbs

This file was deleted.

33 changes: 0 additions & 33 deletions source/ui/story.hbs

This file was deleted.

31 changes: 27 additions & 4 deletions source/ui/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand All @@ -64,7 +64,7 @@ module.exports = function createAppConfig(env, argv)
filename: "js/[name].js",

publicPath: '/',
clean: true,
clean: false,
},

resolve: {
Expand Down Expand Up @@ -161,5 +161,28 @@ 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, {
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",
});

return [config, voyagerConfig];
}

0 comments on commit 8511549

Please sign in to comment.