refactor: output
This commit is contained in:
parent
81fc5f633f
commit
522378aef8
|
@ -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');
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();"}),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -161,10 +161,6 @@ export const hooks = {
|
|||
* Host to bind.
|
||||
*/
|
||||
host: '0.0.0.0',
|
||||
/**
|
||||
* Build path.
|
||||
*/
|
||||
output: 'web',
|
||||
/**
|
||||
* Port to bind.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user