Notice
Recent Posts
Recent Comments
Link
반응형
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 알고리즘
- 삼성소프트웨어아카데미
- 코딩
- 인프런
- 성인학습지
- java
- 일본어독학
- js
- New Architecture
- 모바일앱개발
- 자료구조
- 프로그래머스
- 마이라이트
- 백준
- javascript
- 웹보안
- SWEA
- 일본어공부
- 카카오
- 코딩테스트
- 가벼운학습지
- TurboModule
- 코테
- 삼성
- array
- 가벼운학습지후기
- 자바스크립트
- 자바
- 일본어학습지
- React Native
Archives
- Today
- Total
개발에 AtoZ까지
ERROR in ./src/main.css Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js): 본문
프론트엔드
ERROR in ./src/main.css Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
AtoZ 개발자 2026. 7. 13. 20:28반응형
이슈
ERROR in ./src/main.css
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):

프로젝트 환경
- node.js: 14.20.1
- mini-css-extract-plugin: "^2.7.5"
- webpack: "^5.80.0",
🔍원인
main의 css가 커짐에 따라 작은 용량으로 나누기 위해 mini-css-extract-plugin을 사용하려고 하였습니다. 번들링 된 파일 중 css 파일을 모듈화 시켜주는 로더가 없어서 발생한 이슈였습니다.
💊해결방법
[AS-IS]
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const path = require("path");
module.exports = {
mode: "development",
entry: {
main: "./src/app.js",
},
output: {
filename: "[name].js",
path: path.resolve("./dist"),
},
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader],
},
{
test: /\.(png|jpg|svg|gif)$/,
loader: "url-loader",
options: {
name: "[name].[ext]?[hash]",
limit: 10000, // 10Kb
},
},
],
},
plugins: [new MiniCssExtractPlugin({ filename: `[name].css` })],
[TO-BE]
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const path = require("path");
module.exports = {
mode: "development",
entry: {
main: "./src/app.js",
},
output: {
filename: "[name].js",
path: path.resolve("./dist"),
},
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{
test: /\.(png|jpg|svg|gif)$/,
loader: "url-loader",
options: {
name: "[name].[ext]?[hash]",
limit: 10000, // 10Kb
},
},
],
},
plugins: [new MiniCssExtractPlugin({ filename: `[name].css` })],
MiniCssExtractPlugin.loader는 css를 모듈로 변환시켜주는 기능은 없습니다.
MiniCssExtractPlugin.loader는 split된 css 모듈을 돔에 추가해 주는 역할만 하기 때문에 css를 모듈로 변환 시켜주는 로더가 없어서 발생한 이슈였습니다.
그래서 css를 모듈로 변환해 줄 수 있는 css-loader를 추가해 줘서 해결했습니다.
추가로 MiniCssExtractPlugin.loader와 같이 css 모듈을 돔에 추가해 주는 style-loader이라는 로더가 있습니다. 이 둘은 같은 역할을 하기 때문에 하나만 사용하여야 합니다.
각 로더의 특징들이 있는데 이 부분은 다른 포스트에서 자세히 다뤄보겠습니다.
참고
https://yamoo9.gitbook.io/webpack/webpack/webpack-plugins/extract-css-files
반응형
'프론트엔드' 카테고리의 다른 글
| Expo vs React Native CLI, 2026년 어떤 방식으로 크로스플랫폼을 시작해야할까? (0) | 2026.07.17 |
|---|---|
| React Native 커스텀 네이티브 모듈, New Architecture에선 어떻게 바뀌나 (0) | 2026.07.16 |
| React Native New Architecture 마이그레이션, 어디서부터 확인해야 할까 (0) | 2026.07.15 |
| React Native 0.82부터 레거시 아키텍처를 못 쓰는 이유 (0) | 2026.07.11 |
| Defer / Async 효율적으로 사용하기 (0) | 2026.07.10 |
| Error: FAILURE: Build failed with an exception. (0) | 2026.07.08 |
| [도서] "나는 네이버 프런트엔드 개발자입니다." (0) | 2026.07.07 |
Comments
