diff --git a/src/conf/webpack.config.dev.js b/src/conf/webpack.config.dev.js index 23f7f78..68e76cb 100644 --- a/src/conf/webpack.config.dev.js +++ b/src/conf/webpack.config.dev.js @@ -6,7 +6,6 @@ const HtmlWebpackPlugin = require('html-webpack-plugin'); const CreateSpareWebpackPlugin = require('create-spare-webpack-plugin'); const FriendlyErrorsWebpackPlugin = require('@nuxtjs/friendly-errors-webpack-plugin'); const config = require('./webpack.config'); -const pkg = require('../../package.json'); const paths = require('./path'); module.exports = function (cmd) { @@ -16,11 +15,6 @@ module.exports = function (cmd) { require.resolve('webpack-hot-dev-clients/webpackHotDevClient'), paths.appIndexJs, ]; - config.resolve = { - alias: { - 'rdoc-theme': UPATH.normalizeSafe(paths.appThemePath), - }, - }; config.module.rules = config.module.rules.map((item) => { if (item.oneOf) { const loaders = []; @@ -111,9 +105,7 @@ module.exports = function (cmd) { inject: true, favicon: paths.defaultFaviconPath, template: paths.defaultHTMLPath, - }), - new webpack.DefinePlugin({ - VERSION: JSON.stringify(pkg.version), + title: paths.rdocConf && paths.rdocConf.title ? paths.rdocConf.title : 'Rdoc', }), // 将模块名称添加到工厂功能,以便它们显示在浏览器分析器中。 // 当接收到热更新信号时,在浏览器console控制台打印更多可读性高的模块名称等信息 diff --git a/src/conf/webpack.config.js b/src/conf/webpack.config.js index fb0cda2..71db59d 100644 --- a/src/conf/webpack.config.js +++ b/src/conf/webpack.config.js @@ -1,6 +1,9 @@ const PATH = require('path'); +const webpack = require('webpack'); +const UPATH = require('upath'); const ProgressBarPlugin = require('progress-bar-webpack-plugin'); const paths = require('./path'); +const pkg = require('../../package.json'); module.exports = { entry: {}, @@ -10,6 +13,11 @@ module.exports = { filename: 'js/[name].[hash:8].js', chunkFilename: 'js/[name].[hash:8].js', }, + resolve: { + alias: { + 'rdoc-theme': UPATH.normalizeSafe(paths.appThemePath), + }, + }, module: { rules: [ { @@ -84,6 +92,9 @@ module.exports = { format: ` build [:bar] ${':percent'.green} (:elapsed seconds)`, clear: false, }), + new webpack.DefinePlugin({ + VERSION: JSON.stringify(pkg.version), + }), ], node: { dgram: 'empty', diff --git a/src/conf/webpack.config.prod.js b/src/conf/webpack.config.prod.js index a7a9338..9027207 100755 --- a/src/conf/webpack.config.prod.js +++ b/src/conf/webpack.config.prod.js @@ -1,5 +1,4 @@ const autoprefixer = require('autoprefixer'); -const webpack = require('webpack'); const PATH = require('path'); const UPATH = require('upath'); const HtmlWebpackPlugin = require('html-webpack-plugin'); @@ -9,7 +8,6 @@ const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); const config = require('./webpack.config'); -const pkg = require('../../package.json'); const paths = require('./path'); module.exports = function (cmd) { @@ -17,11 +15,6 @@ module.exports = function (cmd) { config.entry = [paths.appIndexJs]; config.output.filename = 'js/[hash:8].js'; config.output.chunkFilename = 'js/[name].[hash:8].js'; - config.resolve = { - alias: { - 'rdoc-theme': UPATH.normalizeSafe(paths.appThemePath), - }, - }; config.module.rules = config.module.rules.map((item) => { if (item.oneOf) { const loaders = []; @@ -141,6 +134,7 @@ module.exports = function (cmd) { inject: true, favicon: paths.defaultFaviconPath, template: paths.defaultHTMLPath, + title: paths.rdocConf && paths.rdocConf.title ? paths.rdocConf.title : 'Rdoc', minify: { removeAttributeQuotes: true, collapseWhitespace: true, @@ -150,9 +144,6 @@ module.exports = function (cmd) { removeEmptyAttributes: true, }, }), - new webpack.DefinePlugin({ - VERSION: JSON.stringify(pkg.version), - }), new CopyMarkdownImageWebpackPlugin({ dir: cmd.markdownPaths, toDir: config.output.path, diff --git a/templates/default/introduce/api/conf.md b/templates/default/introduce/api/conf.md index 52ddb43..04400a5 100644 --- a/templates/default/introduce/api/conf.md +++ b/templates/default/introduce/api/conf.md @@ -42,6 +42,7 @@ sort: 4 ```json { + "title": "Rdoc title", "theme": "rdoc-theme-load-react", "favicon": "./assets/favicon.ico", "logo": "./assets/rdoc.logo.svg", @@ -55,6 +56,14 @@ sort: 4 1. 优先读取 `.rdocrc.json` 配置。 2. 两种配置只有一种起作用。 +### title + +设置默认网页标题内容。 + +```html +Rdoc title +``` + ### favicon 默认显示 `rdoc` 的图标,自定义 `favicon` 需要自己生成一个图标命名为 `favicon.ico` 放在项目的根目录自动识别。添加配置,可以指定不同文件名和路径下的 `ico` 文件。 diff --git a/theme/default/index.html b/theme/default/index.html index 7c0fd2d..946b8ad 100644 --- a/theme/default/index.html +++ b/theme/default/index.html @@ -2,7 +2,7 @@ - RDoc + <%= htmlWebpackPlugin.options.title %>