inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

프론트엔드 개발환경의 이해와 실습 (webpack, babel, eslint..)

TypeError: compiler.plugin is not a function

해결된 질문

885

seungmidev

작성한 질문수 2

0

const path = require('path');
const MyWebpackPlugin = require("./my-webpack-plugin");

module.exports = {
mode : 'development',
entry: {
main: './src/app.js'
},
output: {
path: path.resolve('./dist'),
filename: '[name].js'
},
module : {
rules : [
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'url-loader',
options: {
publicPath: './dist/',
name: '[name].[ext]?[hash]',
limit: 20000,
}
}
]
},
plugins: [
new MyWebpackPlugin()
]
}
class MyWebpackPlugin {
apply(compiler) {
/*compiler.hooks.done.tap("My Plugin", stats => {
console.log("MyPlugin: done")
})*/

compiler.plugin('emit', (compilation, callback) => {
const source = compilation.assets['main.js'].source();

compilation.assets['main.js'].source = () => {
const banner = [
'/**',
' * 이것은 BannerPlugin이 처리한 결과입니다.',
' * Build Date: 2019-10-10',
' */'
].join('\n');
return banner + '\n' + source;
}

callback();
})
}
}

module.exports = MyWebpackPlugin;

플러그인 부분 따라서 공부하던 중 class myWebpackPlugin을 블로그 소스로 가져온 뒤에 npm run build를 돌렸는데여,

[webpack-cli] TypeError: compiler.plugin is not a function

이런 에러가 발생했어여ㅠ_____ㅠ 왜 그러는걸까여?

웹팩 babel nodejs eslint

답변 1

0

김정환

혹시 웹팩 5 버전을 사용하고 계신가요? 실습에서는 4버전을 사용하고 있습니다. 

비슷한 질문인데 참고해 주세요.

지금 시점에서 해당 강의를 듣는 것에 대하여

1

111

3

2025년 기준 번들러 트렌드와 선택 기준이 궁금합니다 (Webpack, Vite, tsup 등)

1

223

1

에러 해결 공유드립니다

1

224

2

webpack 4 버전과 호환되는 플러그인 버전 공유드립니다

1

233

2

eslint

0

380

3

도와주세요!

0

167

2

[수강 중 트러블슈팅 공유] webpack, webpack-cli 버전

1

145

1

질문 an error occurred while loading the image

1

469

1

webpack에서 babel-loader 사용할때 질문

1

150

1

자주 사용하는 플러그인 에서 질문이 있습니다.

1

168

1

eslint no-extra-semi 관련 질문

1

143

1

webpack5 에서 open index.html하는법 + 질문

1

167

1

TypeError: ((process.env.NODE_ENV === "production") && [MiniCssExtractPlugin]) is not iterable

2

301

1

혹시 웹팩 5 내용으로 강의 업데이트는 안되는건가요?

1

371

1

에러없이 png안뜨시는 분들

1

274

1

Error: Cannot find module 'node:crypto'

1

464

1

DefinePlugin 관련; env와 관련하여, (21.06.22 16:15, aloha_jh) 답변포함

1

406

1

깃허브 확인 문의

0

575

1

폴더를 prettier로 돌렸을 때 나오는 에러 구문에 대한 질문

0

405

1

해쉬값과 캐쉬 갱신

1

461

1

Hash 에러 발생

1

2667

2

webpack.config.js에서의 CommonJS방식에 대한 질문

0

831

3

웹팩 버전

0

524

1

웹팩-cli 버전을 명시하지 않으면 왜 에러가 날까요?

0

484

1