Skip to content

Commit

Permalink
fix(webpack): don't output built logs when pdf and live
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroppy committed Jun 19, 2019
1 parent f4a5e06 commit 041a09a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 26 deletions.
54 changes: 33 additions & 21 deletions packages/fusuma/src/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,23 @@ async function startProcess(basePath) {
);
}

async function buildProcess(basePath, extendedConfig = {}) {
async function buildProcess(basePath, extendedConfig = {}, isOutput = true) {
const spinner = loader('Building with webpack...').start();
const config = merge(await fusuma.read(basePath), extendedConfig);
const remoteOrigin = await getRemoteOriginUrl(basePath);

await deleteDir(join(basePath, 'dist'));
await build({
...config,
internal: {
basePath,
remoteOrigin
}
});
await build(
{
...config,
internal: {
basePath,
remoteOrigin
}
},
isOutput
);

spinner.stop();
}

Expand All @@ -62,12 +66,16 @@ async function pdfProcess(basePath, { input: i, output: o }) {
const input = join(process.cwd(), i || 'dist');
const output = join(process.cwd(), o || 'slide.pdf');

await buildProcess(basePath, {
slide: {
loop: false,
sidebar: false
}
});
await buildProcess(
basePath,
{
slide: {
loop: false,
sidebar: false
}
},
false
);

const spinner = loader('Exporting as PDF...').start();

Expand All @@ -90,13 +98,17 @@ async function pdfProcess(basePath, { input: i, output: o }) {
}

async function live(basePath, { keyword, internal, port, dir }) {
await buildProcess(basePath, {
server: {
port,
isLive: true,
keyword
}
});
await buildProcess(
basePath,
{
server: {
port,
isLive: true,
keyword
}
},
false
);

const spinner = loader('Setup live mode...').start();

Expand Down
4 changes: 2 additions & 2 deletions packages/task-build/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

const { build: webpackBuild } = require('@fusuma/webpack');

async function build(config) {
async function build(config, isOutput) {
if (process.env.NODE_ENV === undefined) process.env.NODE_ENV = 'production';

await webpackBuild(config);
await webpackBuild(config, isOutput);
}

module.exports = build;
10 changes: 7 additions & 3 deletions packages/webpack/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ function start(config, cb) {
webpackDevServer(combineConfig(config), cb);
}

function build(config) {
function build(config, isOutput = true) {
const webpack = require('webpack');
const outputBuildInfo = require('./outputBuildInfo');

return new Promise((resolve, reject) => {
webpack(combineConfig(config), (err, res) => {
if (err) reject(err);
if (err) {
return reject(err);
}

outputBuildInfo(res);
if (isOutput) {
outputBuildInfo(res);
}

resolve();
});
Expand Down

0 comments on commit 041a09a

Please sign in to comment.