Skip to content

Commit 05004d9

Browse files
committed
build index page with title
1 parent 8a2ece0 commit 05004d9

File tree

4 files changed

+83
-25
lines changed

4 files changed

+83
-25
lines changed

web/build/webpack.prod.conf.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const utils = require('./utils');
33
const webpack = require('webpack');
44
const config = require('../config');
55
const merge = require('webpack-merge');
6+
const fs = require('fs-extra');
7+
const jsYaml = require('js-yaml');
68
const baseWebpackConfig = require('./webpack.base.conf');
79
const CopyWebpackPlugin = require('copy-webpack-plugin');
810
const HtmlWebpackPlugin = require('html-webpack-plugin');
@@ -11,6 +13,14 @@ const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');
1113

1214
const env = config.build.env;
1315

16+
let webConfig;
17+
try {
18+
webConfig = jsYaml.safeLoad(fs.readFileSync('../config.yml'), 'utf8').web;
19+
} catch (e) {
20+
console.error('[ERROR][LoadConfig] CONFIGURATION:', e);
21+
process.exit(1);
22+
}
23+
1424
const webpackConfig = merge(baseWebpackConfig, {
1525
module: {
1626
rules: utils.styleLoaders({
@@ -51,8 +61,9 @@ const webpackConfig = merge(baseWebpackConfig, {
5161
// you can customize output by editing /index.html
5262
// see https://github.com/ampedandwired/html-webpack-plugin
5363
new HtmlWebpackPlugin({
64+
title: webConfig.title,
5465
filename: config.build.index,
55-
template: 'index.html',
66+
template: 'index.ejs',
5667
inject: true,
5768
minify: {
5869
removeComments: true,

web/index.html renamed to web/index.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset="utf-8">
5-
<title>nyaa-stats-web</title>
5+
<title><%= htmlWebpackPlugin.options.title %></title>
66
</head>
77
<body>
88
<div id="app"></div>

web/package-lock.json

Lines changed: 68 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@
4545
"extract-text-webpack-plugin": "^3.0.0",
4646
"file-loader": "^1.1.4",
4747
"friendly-errors-webpack-plugin": "^1.6.1",
48+
"fs-extra": "^5.0.0",
4849
"html-webpack-plugin": "^2.30.1",
4950
"http-proxy-middleware": "^0.17.3",
51+
"js-yaml": "^3.10.0",
5052
"opn": "^5.1.0",
5153
"optimize-css-assets-webpack-plugin": "^3.2.0",
5254
"ora": "^1.2.0",

0 commit comments

Comments
 (0)