ํฐ์คํ ๋ฆฌ ๋ทฐ
๋ฌธ์
ํ๋ก์ ํธ ๋์ค Webpack์ ํตํด ๋ฒ๋ค๋ง ๋ ๊ฒฐ๊ณผ๋ฌผ์ ์๋ฒ์ ๋์ฐ๋ html head ํ๊ทธ ๋ด์ ์ ์ฉํ๋ favicons ์ด๋ฏธ์ง๊ฐ ์ ์ฉ๋์ง ์๋ ๋ฌธ์ ๊ฐ ๋ฐ์ํจ๊ณผ ๋์์ ๋ค์๊ณผ ๊ฐ์ ์๋ฌ๊ฐ ๋ฐ์ํ์๋ค.
MIME type ('text/html') is not a supported stylesheet MIME type
ํด๋น ์๋ฌ์ ๋ํด์ ๊ฒ์์ ํด๋ณด๋,
MIME type ('text/html') is not a supported stylesheet MIME type
I have tried almost every solution for the problem which includes. giving type for use of app.use(express.static('public')) and many more but it s...
stackoverflow.com
์ค๋ฅ๋ฅผ ๋ฐ์์ํค๋ ๋ฐ์ ์ฌ๋ฌ ์์ธ์ด ์์ง๋ง ๊ทธ ์ค์์ cssํ์ผ์ ๊ฒฝ๋ก๋ช ์ด ์๋ชป ์ง์ ๋์ด ์์ ๋๊ฐ ๊ฐ์ฅ ์ฃผ๋ ์์ธ ์ค ํ๋์๋ค.
์ฒ์์๋ favicons ์ด๋ฏธ์ง์ ์ฌ์ฉ๋๋ ์์ค์ ํ์ฅ์๋ .png ํ์์ด๋๊น ๋ฒ๋ค๋ง๋๋ ๊ณผ์ ์์ file-loader์ ์ํด ๋ถ๋ฌ์ ์ ธ์ผ ๋๋๊ฒ ์๋์ง ํ์ฐธ์ ๊ณ ๋ฏผํ์ง๋ง ๊ฒฐ๊ณผ์ ์ผ๋ก Webpack์ Plugins๊ณผ module์ ์ฐจ์ด๋ฅผ ์ ํํ ์์งํ๊ณ ์์ง ์์ ๋ฐ์์ ์จ ์ค์์๋ค.
file-loader๋ ๋ชจ๋์ด๋ค. ์์ค์ฝ๋์์ ์ฌ์ฉํ๋ ๋ชจ๋ ํ์ผ์ ๋ชจ๋๋ก ์ฌ์ฉํ๊ฒ๋ ํ ์ ์์ผ๋ฉฐ ํ์ผ์ ๋ชจ๋ ํํ๋ก ์ง์ํ๊ณ ์นํฉ ์์ํ์ ํ์ผ์ ์ฎ๊ฒจ์ฃผ๋ ์ญํ ์ ํ๋ค.
์ฆ, loader์ ์ผํ์ธ file-loaer๋ ํ์ผ์ ํด์ํ๊ณ ๋ณํํ๋ ๊ณผ์ ์ ๊ด์ฌํ์ฌ ๋ชจ๋์ ์ฒ๋ฆฌํ๊ธฐ ๋๋ฌธ์ ๊ธฐ์กด์ html head ํ๊ทธ ๋ด์์ link ํ๊ทธ๋ก ์ด๋ฏธ์ง๋ฅผ ๋ถ๋ฌ์ค๋ ๊ณผ์ ์ ๊ด์ฌํ์ง ๋ชปํ ๊ฒ์ด๋ค.html๊ณผ ๊ฐ์ ๊ฒฝ์ฐ์๋ Webpack ๋ฒ๋ค๋ง ๊ณผ์ ์ ์ง์ ์ ์ผ๋ก ๊ด์ฌ๋์ง ์๊ณ ์ต์ข ๋ฒ๋ค๋ง๋ ๊ฒฐ๊ณผ๋ฌผ์ patchํ๋ ํ ํ๋ฆฟ์ ์ญํ ์ ํ๊ธฐ ๋๋ฌธ์ด๋ค.
๊ฒฐ๊ตญ ๋ฒ๋ค๋ง๋ ๊ฒฐ๊ณผ๋ฌผ์ ํํ๋ฅผ ๋ฐ๊พธ๊ธฐ ์ํด์๋ ๋ณ๋์ plugin์ด ํ์ํ๋ ๊ฒ์ด๋ค.
๋ฌธ์ ํด๊ฒฐ
https://www.npmjs.com/package/favicons-webpack-plugin
favicons-webpack-plugin
Let webpack generate all your favicons and icons for you
www.npmjs.com
๊ตฌ๊ธ๋ง์ ํด๋ณด๋ favicons ์ ์ฉํ ์ ์๋ ๋ณ๋์ favicons-webpack-plugin์ด ์์ด ๋ค์๊ณผ ๊ฐ์ด ์ฝ๋๋ฅผ ์ถ๊ฐํ์๋ค.
favicons-webpack-plugin์ ์ง์ ํ path์ ์๋ ์ด๋ฏธ์ง ์์ค๋ฅผ ๋ณ๋๋ก output ํด๋์ ์ ์ฅ์ ํ ๋ค, ํด๋น ํ์ผ์ ๊ฒฝ๋ก๋ฅผ ์๋์ผ๋ก head ํ๊ทธ ๋ด link ํ๊ทธ์ href ์ดํธ๋ฆฌ๋ทฐํธ์ patchํด์ค๋ค
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
(...)
plugins: [
new HtmlWebpackPlugin({
title: 'MovieInfoService',
template: './template.hbs',
meta: {
author: "CHOI",
description: "This site is where people see a various of movie info and evaluate it",
viewport: 'width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1'
},
(...)
new FaviconsWebpackPlugin('./src/img/favicon.png')
]
์ฌ๊ธฐ์ ํ๋ฌ๊ทธ์ธ์ ์ ์ฉํ ๋ ๋ค์๊ณผ ๊ฐ์ ์๋ฌ๊ฐ ๋ฐ์ํ์๋๋ฐ,
ERROR in FaviconsWebpackPlugin - This FaviconsWebpackPlugin version is not compatible with your current HtmlWebpackPlugin version. Please upgrade to HtmlWebpackPlugin >= 4 OR downgrade to FaviconsWebpackPlugin 2.x
ํด์ ์๋ฏธ ๊ทธ๋๋ก FaviconsWebpackPlugin์ HtmlWebpackPlugin๊ณผ ๋ฒ์ ์ด ์์ํด์ผ ๋๋ค๋ ๋ด์ฉ์ด์๋ค.
ํ์ฌ ํ๋ก์ ํธ์ ์ฐ์ด๋ HtmlWebpackPlugin๊ณผ ๊ฐ์ ๊ฒฝ์ฐ๋ ๋ฒ์ 3์ ์ฌ์ฉํ๊ณ ์์๊ณ ์ด์ ๋ง๋ FaviconsWebpackPlugin์ ๋ฒ์ ์
2์ด๊ธฐ ๋๋ฌธ์ ์ด๋ก ๋ค์ด๊ทธ๋ ์ด๋ํ๊ณ ๋๋ ์ ์์ ์ผ๋ก ๋์ํ๋ ๊ฒ์ ํ์ธํ์๋ค.

๋น๋ํ ๊ฒฐ๊ณผ ๊ธฐ์กด์ img ํด๋ ๋ด์ ์กด์ฌํ๋ ์ด๋ฏธ์ง ์์ค๊ฐ ๋ฒ๋ค๋ง ํด๋ ๋ด์ ๋ณ๋์ ํ์ผ๋ก ์๋ก ์์ฑ๋์์์ ํ์ธํ์๋ค.
'Webpack' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
favicons-webpack-plugin์ copy-webpack-plugin์ผ๋ก ๋ฆฌํฉํ ๋งํ๊ธฐ (0) | 2021.08.13 |
---|---|
htmlํ์ผ์ cssํ์ผ์ ์ถ๊ฐํ์ฌ ๋ฒ๋ค๋งํ๋ ๊ณผ์ ์์์ ์ค์ (0) | 2021.08.13 |