Skip to content

Commit

Permalink
fix(webpack): add output log
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroppy committed Jun 30, 2019
1 parent f3e4b4d commit 04a3521
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 16 deletions.
10 changes: 8 additions & 2 deletions packages/fusuma/src/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function startProcess(basePath) {
}

async function buildProcess(basePath, extendedConfig = {}, isConsoleOutput = true) {
const spinner = loader('Building with webpack...').start();
const spinner = loader('Rendering components to HTML...').start();
const config = fusuma.combine(await fusuma.read(basePath), extendedConfig);
const remoteOrigin = await getRemoteOriginUrl();

Expand All @@ -43,7 +43,13 @@ async function buildProcess(basePath, extendedConfig = {}, isConsoleOutput = tru
remoteOrigin
}
},
isConsoleOutput
isConsoleOutput,
(type) => {
if (type == 'start-build') {
spinner.color = 'yellow';
spinner.text = 'Building with webpack...';
}
}
);

spinner.stop();
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, isOutput) {
async function build(config, isOutput, cb) {
if (process.env.NODE_ENV === undefined) process.env.NODE_ENV = 'production';

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

module.exports = build;
15 changes: 11 additions & 4 deletions packages/webpack/src/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,26 @@ async function build(c, { body, fusumaProps }) {

const compiler = webpack(config);

compiler.run((err) => {
compiler.run((err, stats) => {
if (err) {
return reject(err);
}
resolve();
resolve(stats);
});
});
}

async function buildProcess(c) {
async function buildProcess(c, cb) {
cb('start-ssr');

const data = await ssr(c);

await build(c, data);
cb('finish-ssr');
cb('start-build');

return await build(c, data);

cb('finish-build');
}

module.exports = buildProcess;
9 changes: 7 additions & 2 deletions packages/webpack/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ async function start(config) {
return await server(combineConfig('development', config), { port: 8080 });
}

async function build(config, isConsoleOutput = true) {
async function build(config, isConsoleOutput = true, cb) {
const buildTask = require('./build');
const stats = await buildTask(config, cb);

return await buildTask(config);
if (isConsoleOutput) {
const outputBuildInfo = require('./outputBuildInfo');

outputBuildInfo(stats);
}
}

module.exports = {
Expand Down
17 changes: 11 additions & 6 deletions packages/webpack/src/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ module.exports = (type, { meta, slide, extends: fileExtends, internal = {}, serv
'process.env.CHART': JSON.stringify(chart),
'process.env.SSR': JSON.stringify(type === 'ssr')
}),
new ImageminWebpWebpackPlugin({
detailedLogs: false,
silent: true
})
]
};

if (type !== 'ssr') {
common.plugins.push(
new HtmlWebpackPlugin({
url,
filename: 'index.html',
Expand All @@ -151,13 +160,9 @@ module.exports = (type, { meta, slide, extends: fileExtends, internal = {}, serv
collapseWhitespace: true
}
: false
}),
new ImageminWebpWebpackPlugin({
detailedLogs: false,
silent: true
})
]
};
);
}

if (type !== 'ssr') {
if (jsPath && jsPath.match(/\+*.js$/i)) {
Expand Down

0 comments on commit 04a3521

Please sign in to comment.