refactor: code

This commit is contained in:
endiliey 2018-08-08 14:25:02 +08:00
parent a9c3d50a68
commit 44122cd202
4 changed files with 37 additions and 48 deletions

View file

@ -1,4 +1,6 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpackNiceLog = require('webpack-nicelog');
const createBaseConfig = require('./base');
module.exports = function createDevConfig(props) {
@ -6,5 +8,21 @@ module.exports = function createDevConfig(props) {
config.entry('main').add(path.resolve(__dirname, '../core/devEntry.js'));
const {siteConfig} = props;
config.plugin('html-webpack-plugin').use(HtmlWebpackPlugin, [
{
inject: false,
hash: true,
template: path.resolve(__dirname, '../core/devTemplate.ejs'),
filename: 'index.html',
title: siteConfig.title
}
]);
config.plugin('WebpackNiceLog').use(webpackNiceLog, [
{
name: 'Development'
}
]);
return config;
};

View file

@ -1,5 +1,6 @@
const path = require('path');
const staticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin');
const webpackNiceLog = require('webpack-nicelog');
const createBaseConfig = require('./base');
module.exports = function createProdConfig(props) {
@ -13,9 +14,8 @@ module.exports = function createProdConfig(props) {
const {siteConfig, docsData, pagesData} = props;
// Find all available paths
// Find all available paths to be rendered
const paths = [...docsData, ...pagesData].map(data => data.path);
config.plugin('StaticSiteGenerator').use(staticSiteGeneratorPlugin, [
{
entry: 'main',
@ -27,6 +27,11 @@ module.exports = function createProdConfig(props) {
paths
}
]);
config.plugin('WebpackNiceLog').use(webpackNiceLog, [
{
name: 'Production'
}
]);
return config;
};