Changeset View
Changeset View
Standalone View
Standalone View
run-admin.js
const locreq = require('locreq')(__dirname); | const locreq = require('locreq')(__dirname); | ||||
const webpack = require('webpack'); | const webpack = require('webpack'); | ||||
const config = require('./webpack.config'); | const config = require('./webpack.config'); | ||||
const path = require('path'); | const path = require('path'); | ||||
const fs = require('fs'); | const fs = require('fs'); | ||||
require('colors'); | require('colors'); | ||||
module.exports = async function(sitemap_path, debug_opt) { | module.exports = async function(sitemap_path, debug_opt) { | ||||
const outDir = locreq.resolve('./public-admin'); | const outDir = locreq.resolve('./public-admin'); | ||||
const { app, plugins_path } = await require(sitemap_path)(); | const { app, ec_path } = await require(sitemap_path)(); | ||||
let plugins_available = require('./utils/are-plugins-avaliable')( | let ec_available = require('./utils/are-external-components-avaliable')( | ||||
plugins_path | ec_path | ||||
); | ); | ||||
let expanded_plugins_path = | let expanded_ec_path = path.relative(ec_path || '.', '/') + ec_path; | ||||
path.relative(plugins_path || '.', '/') + plugins_path; | |||||
app.WwwServer.static_route(outDir, ''); | app.WwwServer.static_route(outDir, ''); | ||||
const compiler = webpack( | const compiler = webpack(config(ec_available ? [expanded_ec_path] : [])); | ||||
config(plugins_available ? [expanded_plugins_path] : []) | |||||
); | |||||
compiler.watch( | compiler.watch( | ||||
{ | { | ||||
aggregateTimeout: 100, | aggregateTimeout: 100, | ||||
poll: true, | poll: true, | ||||
}, | }, | ||||
(err, stats) => { | (err, stats) => { | ||||
if (err) throw new Error(err); | if (err) throw new Error(err); | ||||
//Detailed compiler output | //Detailed compiler output | ||||
if (debug_opt) console.log(stats); | if (debug_opt) console.log(stats); | ||||
console.log('Build successful'.blue.bgYellow); | console.log('Build successful'.blue.bgYellow); | ||||
} | } | ||||
); | ); | ||||
}; | }; |