Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack 配置文件 #19

Open
suukii opened this issue Jul 12, 2020 · 0 comments
Open

webpack 配置文件 #19

suukii opened this issue Jul 12, 2020 · 0 comments
Labels

Comments

@suukii
Copy link
Owner

suukii commented Jul 12, 2020

webpack.config.js 是 webpack 的默认打包配置文件,也可以通过 npx webpack --config [name] 来设置。

常用配置项

  • mode:打包环境,分为 productiondevelopment,生产环境下代码会被压缩
  • 多入口:在 entry 中指定多个值
  • 为打包后的 JS 加前缀:在 output 中指定 publicPath
  • devtool:就是去配置 sourcemap,方便调试,准确定位到代码错误:
    • cheap:定位到行,不定位到列
    • module:把依赖模块中的代码一并做映射
    • eval:使用 eval 形式做 sourcemap 映射
    • inline:行内的映射关系

推荐的 devtool 配置:

// dev
devtool: 'cheap-module-eval-source-map'

// prod
devtool: 'cheap-module-source-map'
@suukii suukii added the webpack label Jul 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant