Skip to content

Commit 85c627d

Browse files
committed
fix: Add missing lang attribute on HTML element
Fixes #879 #1668
1 parent 804e314 commit 85c627d

File tree

6 files changed

+367
-255
lines changed

6 files changed

+367
-255
lines changed

package-lock.json

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
"dependencies": {
3131
"@tippyjs/react": "4.1.0",
32-
"@vxna/mini-html-webpack-template": "^1.0.0",
32+
"@vxna/mini-html-webpack-template": "^2.0.0",
3333
"acorn": "^6.4.1",
3434
"acorn-jsx": "^5.1.0",
3535
"ast-types": "~0.13.2",
@@ -67,7 +67,7 @@
6767
"lodash": "^4.17.15",
6868
"lowercase-keys": "^2.0.0",
6969
"markdown-to-jsx": "^6.11.4",
70-
"mini-html-webpack-plugin": "^2.0.0",
70+
"mini-html-webpack-plugin": "^3.1.3",
7171
"mri": "^1.1.4",
7272
"ora": "^4.0.2",
7373
"prismjs": "^1.17.1",
@@ -164,7 +164,7 @@
164164
"tapable": "^1.1.3",
165165
"typescript": "^3.8.3",
166166
"url-loader": "^2.2.0",
167-
"webpack": "^4.41.2",
167+
"webpack": "^4.44.2",
168168
"webpack-cli": "^3.3.9"
169169
},
170170
"scripts": {

src/scripts/make-webpack-config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from 'path';
22
import castArray from 'lodash/castArray';
33
import webpack, { Configuration, Resolve } from 'webpack';
44
import TerserPlugin from 'terser-webpack-plugin';
5-
import MiniHtmlWebpackPlugin from 'mini-html-webpack-plugin';
5+
import { MiniHtmlWebpackPlugin } from 'mini-html-webpack-plugin';
66
import MiniHtmlWebpackTemplate from '@vxna/mini-html-webpack-template';
77
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
88
import CopyWebpackPlugin from 'copy-webpack-plugin';
@@ -34,6 +34,7 @@ export default function (
3434
const templateContext = isFunction(config.template) ? {} : config.template;
3535
const htmlPluginOptions = {
3636
context: {
37+
lang: 'en',
3738
...templateContext,
3839
title: config.title,
3940
container: config.mountPointId,

src/scripts/utils/StyleguidistOptionsPlugin.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { Tapable } from 'tapable';
2-
import { Compiler, compilation } from 'webpack';
1+
import { compilation, Compiler, WebpackPluginInstance, loader } from 'webpack';
32
import * as Rsg from '../../typings';
43

54
// Webpack plugin that makes Styleguidist config available for Styleguidist webpack loaders.
@@ -8,22 +7,24 @@ import * as Rsg from '../../typings';
87
// Other working in webpack 2 way is to use LoaderOptionsPlugin, but it has problems.
98
// See this issue for details: https://github.com/styleguidist/react-styleguidist/issues/328
109

11-
export default class StyleguidistOptionsPlugin implements Tapable.Plugin {
10+
export default class StyleguidistOptionsPlugin implements WebpackPluginInstance {
1211
private options: Rsg.SanitizedStyleguidistConfig;
12+
1313
public constructor(options: Rsg.SanitizedStyleguidistConfig) {
1414
this.options = options;
15-
this.plugin = this.plugin.bind(this);
1615
}
1716

18-
public plugin(compil: compilation.Compilation) {
19-
const pluginFunc = (context: Rsg.StyleguidistLoaderContext, module: { resource?: boolean }) => {
20-
if (!module.resource) {
21-
return;
22-
}
23-
context._styleguidist = this.options;
24-
};
25-
compil.hooks.normalModuleLoader.tap('StyleguidistOptionsPlugin', pluginFunc);
26-
}
17+
private pluginFunc = (context: Rsg.StyleguidistLoaderContext, module: loader.LoaderContext) => {
18+
if (!module.resource) {
19+
return;
20+
}
21+
context._styleguidist = this.options;
22+
};
23+
24+
private plugin = (compil: compilation.Compilation) => {
25+
// FIXME: Find out how to type it properly
26+
compil.hooks.normalModuleLoader.tap('StyleguidistOptionsPlugin', this.pluginFunc as any);
27+
};
2728

2829
public apply(compiler: Compiler) {
2930
compiler.hooks.compilation.tap('StyleguidistOptionsPlugin', this.plugin);

src/scripts/utils/ensureWebpack.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ if (!webpackVersion) {
1414
throw new StyleguidistError(
1515
'Webpack is required for Styleguidist, please add it to your project:\n\n' +
1616
' npm install --save-dev webpack\n\n' +
17-
'See how to configure it for your style guide:\n' +
17+
'See how to configure webpack for your style guide:\n' +
1818
consts.DOCS_WEBPACK
1919
);
2020
} else if (webpackVersion < MIN_WEBPACK_VERSION) {
2121
throw new StyleguidistError(
22-
`Webpack ${webpackVersion} is not supported by Styleguidist, the minimum version is ${MIN_WEBPACK_VERSION}`
22+
`Webpack ${webpackVersion} is not supported by Styleguidist, the minimum supported version is ${MIN_WEBPACK_VERSION}`
2323
);
2424
}

src/typings/dependencies/mini-html-webpack-plugin.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)