refactor: folder structure & filename

This commit is contained in:
endiliey 2018-08-01 16:55:53 +08:00
parent 9070fb50ab
commit dbf78c5c14
10 changed files with 79 additions and 74 deletions

View file

@ -13,8 +13,8 @@ const serve = require('webpack-serve');
const serveWaitpage = require('webpack-serve-waitpage'); const serveWaitpage = require('webpack-serve-waitpage');
const webpackNiceLog = require('webpack-nicelog'); const webpackNiceLog = require('webpack-nicelog');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const load = require('./loader'); const load = require('../loader');
const createDevConfig = require('./webpack/dev'); const createDevConfig = require('../webpack/dev');
async function getPort(port) { async function getPort(port) {
portfinder.basePort = parseInt(port, 10) || 8080; portfinder.basePort = parseInt(port, 10) || 8080;
@ -61,7 +61,7 @@ module.exports = async function dev(sourceDir, cliOptions = {}) {
{ {
inject: false, inject: false,
hash: true, hash: true,
template: path.resolve(__dirname, 'core/index.html'), template: path.resolve(__dirname, '../core/index.html'),
filename: 'index.html' filename: 'index.html'
} }
]); ]);

View file

@ -1,2 +1,7 @@
exports.dev = require('./dev'); const dev = require('./commands/dev');
exports.build = require('./build'); const build = require('./commands/build');
module.exports = {
dev,
build
};

View file

@ -25,12 +25,12 @@ module.exports = async function load(sourceDir) {
? path.resolve(siteConfig.dest) ? path.resolve(siteConfig.dest)
: path.resolve(sourceDir, '.blogi/dist'); : path.resolve(sourceDir, '.blogi/dist');
// resolve the path of our app theme/ layout // resolve the path of our app user interface layout
const themePath = const uiPath =
!siteConfig.themePath || !siteConfig.uiPath ||
!fs.existsSync(path.resolve(sourceDir, siteConfig.themePath)) !fs.existsSync(path.resolve(sourceDir, siteConfig.uiPath))
? path.resolve(__dirname, '../theme') ? path.resolve(__dirname, '../ui')
: siteConfig.themePath; : siteConfig.uiPath;
const publicPath = siteConfig.base || '/'; const publicPath = siteConfig.base || '/';
@ -39,7 +39,7 @@ module.exports = async function load(sourceDir) {
blogDatas, blogDatas,
sourceDir, sourceDir,
outDir, outDir,
themePath, uiPath,
publicPath publicPath
}; };
}; };

View file

@ -2,7 +2,7 @@ const Config = require('webpack-chain');
const path = require('path'); const path = require('path');
module.exports = function createBaseConfig(props) { module.exports = function createBaseConfig(props) {
const {outDir, themePath, sourceDir, publicPath} = props; const {outDir, uiPath, sourceDir, publicPath} = props;
const config = new Config(); const config = new Config();
const isProd = process.env.NODE_ENV === 'production'; const isProd = process.env.NODE_ENV === 'production';
@ -17,7 +17,7 @@ module.exports = function createBaseConfig(props) {
config.resolve config.resolve
.set('symlinks', true) .set('symlinks', true)
.alias.set('@theme', themePath) .alias.set('@ui', uiPath)
.set('@source', sourceDir) .set('@source', sourceDir)
.set('@generated', path.resolve(__dirname, '../generated')) .set('@generated', path.resolve(__dirname, '../generated'))
.set('@core', path.resolve(__dirname, '../core')) .set('@core', path.resolve(__dirname, '../core'))

View file

@ -4,7 +4,7 @@ const createBaseConfig = require('./base');
module.exports = function createDevConfig(props) { module.exports = function createDevConfig(props) {
const config = createBaseConfig(props); const config = createBaseConfig(props);
config.entry('main').add(path.resolve(__dirname, '../core/index.js')); config.entry('main').add(path.resolve(__dirname, '../core/devEntry.js'));
return config; return config;
}; };