mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 23:57:22 +02:00
refactor: folder structure & filename
This commit is contained in:
parent
9070fb50ab
commit
dbf78c5c14
10 changed files with 79 additions and 74 deletions
|
@ -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'
|
||||||
}
|
}
|
||||||
]);
|
]);
|
|
@ -19,7 +19,7 @@ class App extends React.Component {
|
||||||
<div key={path}>
|
<div key={path}>
|
||||||
<Link to={path}>{path}</Link>
|
<Link to={path}>{path}</Link>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
|
@ -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
|
||||||
|
};
|
||||||
|
|
|
@ -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
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -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'))
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue