refactor: output

This commit is contained in:
cha0s 2024-01-11 05:05:16 -06:00
parent 81fc5f633f
commit 522378aef8
5 changed files with 12 additions and 10 deletions

View File

@ -67,7 +67,7 @@ export const hooks = {
const {exec} = plugin.options;
plugin.options.exec = (compilation) => {
plugin.options.args = [join(config.output.path, compilation.getPath(exec))];
return join('..', 'node_modules', '.bin', 'electron');
return join('..', '..', 'node_modules', '.bin', 'electron');
};
}
}

View File

@ -1,3 +1,5 @@
const {join} = require('path');
const {
banner,
defaultConfig,
@ -7,6 +9,10 @@ const {
const runtime = require('./runtime');
const startServer = require('./start');
const {
FLECKS_CORE_ROOT = process.cwd(),
} = process.env;
module.exports = async (env, argv, flecks) => {
const {
hot,
@ -20,6 +26,7 @@ module.exports = async (env, argv, flecks) => {
},
output: {
libraryTarget: 'commonjs2',
path: join(FLECKS_CORE_ROOT, 'dist', 'server'),
},
plugins: [
banner({banner: "require('source-map-support').install();"}),

View File

@ -193,7 +193,7 @@ module.exports = async (env, argv, flecks) => {
output: {
chunkFilename: isProduction ? 'assets/[name].[contenthash:8].js' : 'assets/[name].js',
filename: isProduction ? 'assets/[name].[contenthash:8].js' : 'assets/[name].js',
path: join(FLECKS_CORE_ROOT, 'dist', flecks.get('@flecks/web/server.output')),
path: join(FLECKS_CORE_ROOT, 'dist', 'web'),
publicPath: '/',
},
plugins,

View File

@ -25,7 +25,6 @@ export const createHttpServer = async (flecks) => {
devHost,
devPort,
host,
output,
port,
} = flecks.get('@flecks/web/server');
const app = express();
@ -104,18 +103,18 @@ export const createHttpServer = async (flecks) => {
}
else {
// Serve the document root, sans index.
app.use(express.static(join(FLECKS_CORE_ROOT, 'dist', output), {index: false}));
app.use(express.static(join(FLECKS_CORE_ROOT, 'dist', 'web'), {index: false}));
// Tests bypass middleware and stream processing.
app.get('/tests.html', (req, res) => {
res.setHeader('Content-Type', 'text/html; charset=UTF-8');
const stream = createReadStream(join(FLECKS_CORE_ROOT, 'dist', output, 'tests.html'));
const stream = createReadStream(join(FLECKS_CORE_ROOT, 'dist', 'web', 'tests.html'));
stream.pipe(res);
});
// Fallback to serving HTML.
app.get('*', routeMiddleware, async (req, res) => {
if (req.accepts('text/html')) {
res.setHeader('Content-Type', 'text/html; charset=UTF-8');
const stream = createReadStream(join(FLECKS_CORE_ROOT, 'dist', output, 'index.html'));
const stream = createReadStream(join(FLECKS_CORE_ROOT, 'dist', 'web', 'index.html'));
deliverHtmlStream(stream, flecks, req, res);
}
else {

View File

@ -161,10 +161,6 @@ export const hooks = {
* Host to bind.
*/
host: '0.0.0.0',
/**
* Build path.
*/
output: 'web',
/**
* Port to bind.
*/