回答編集履歴
2
loading fontsのリンクを追加、説明追記
answer
CHANGED
@@ -7,6 +7,11 @@
|
|
7
7
|
[Loading CSS - Asset Management | webpackjs.org](https://webpack.js.org/guides/asset-management/#loading-css)
|
8
8
|
|
9
9
|
今回のkatex.cssの場合は、CSSからフォントファイル(ttf,woff,woff2)も読み込まれているので、フォントファイルに対してもloaderを設定する必要があります。
|
10
|
+
[Loading Fonts - Asset Management | webpackjs.org](https://webpack.js.org/guides/asset-management/#loading-fonts)
|
11
|
+
|
12
|
+
必要なloaderの設定としては下記のとおりです。
|
13
|
+
(`npm install --save-dev style-loader css-loader file-loader`をお忘れなく。)
|
14
|
+
|
10
15
|
```javascript
|
11
16
|
// webpack.config.js の一部
|
12
17
|
rules: [
|
1
webpack.config.jsの一部を追記
answer
CHANGED
@@ -1,4 +1,27 @@
|
|
1
1
|
試してみたところ、KaTeXのCSSファイルを読み込めていないとそのような表示になってしまうようです。
|
2
2
|
> Note that you have to bundle the stylesheet (katex.css) or include it manually.
|
3
3
|
>
|
4
|
-
[Browser · KaTeX](https://khan.github.io/KaTeX/docs/browser.html#bundler)
|
4
|
+
[Browser · KaTeX](https://khan.github.io/KaTeX/docs/browser.html#bundler)
|
5
|
+
|
6
|
+
CSSファイルをwebpackから利用できるようにするにはwebpack.config.jsにloaderを記述する必要があります。
|
7
|
+
[Loading CSS - Asset Management | webpackjs.org](https://webpack.js.org/guides/asset-management/#loading-css)
|
8
|
+
|
9
|
+
今回のkatex.cssの場合は、CSSからフォントファイル(ttf,woff,woff2)も読み込まれているので、フォントファイルに対してもloaderを設定する必要があります。
|
10
|
+
```javascript
|
11
|
+
// webpack.config.js の一部
|
12
|
+
rules: [
|
13
|
+
{
|
14
|
+
test: /.css$/,
|
15
|
+
use: [
|
16
|
+
'style-loader',
|
17
|
+
'css-loader'
|
18
|
+
]
|
19
|
+
},
|
20
|
+
{
|
21
|
+
test: /.(ttf|woff2?)$/,
|
22
|
+
use: [
|
23
|
+
'file-loader'
|
24
|
+
]
|
25
|
+
}
|
26
|
+
]
|
27
|
+
```
|