Questions tagged [webpack]

Webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it can also transform, bundle, or package just about any resource or asset. Webpack takes modules with dependencies and generates static assets representing those modules. Webpack enables extensibility and promotes best practices in web architecture and performance.

Introduction

Webpack is a bundler for modules. The main purpose is to bundle JavaScript files for usage in a browser, yet it can also transform, bundle, or package just about any resource or asset.

TL;DR

  • Bundles ES Modules, CommonJS, and AMD modules (even combined).
  • Can create a single bundle or multiple chunks that are asynchronously loaded at runtime (to reduce initial loading time).
  • Dependencies are resolved during compilation, reducing the runtime size.
  • Loaders can preprocess files while compiling, e.g., TypeScript to JavaScript, Handlebars strings to compiled functions, images to Base64, etc.
  • Highly modular plugin system to do whatever else your application requires.

Get Started

Check out webpack's quick Get Started guide and the other guides.

Browser Compatibility

Webpack supports all browsers that are ES5-compliant (IE8 and below are not supported). Webpack also needs Promise for import() and require.ensure(). If you want to support older browsers, you will need to load a polyfill before using these expressions.

Support

Webpack Open Collective - Help support the teams' ongoing development efforts.

Community

Webpack Examples

Webpack Examples - Examples of common Webpack functionality.

License

MIT

Links

GitHub

Website

42504 questions
13
votes
3 answers

Vue 3 Package Update Errors

Vue 3 app broken/will not compile following package update. Zero errors prior to update. I am receiving the following node console errors. Errors "export 'createElementBlock' (imported as '_createElementBlock') was not found in 'vue' "export…
Ryan Prentiss
  • 1,492
  • 2
  • 25
  • 46
13
votes
1 answer

How to setup the TypeScript compiler for the library so that the unused modules will be cut off by Webpack in the dependents projects?

Preliminary explanations about subject library I am sorry about taking your time by making you read this. I wrote it to answer the questions like "What are you doing?" and "Why are you doing this?". The library consists from a large number of helper…
Takeshi Tokugawa YD
  • 670
  • 5
  • 40
  • 124
13
votes
2 answers

Import statements in Nodejs with Typescript is not resolving with absolute path after compiling

I am trying to write a server in NodeJs using Typescript. I have installed these devDependencies: "@types/config": "^0.0.38", "@types/express": "^4.17.12", "@types/jsonwebtoken": "^8.5.1", "@types/lodash": "^4.14.170", …
bhawanishiv
  • 345
  • 3
  • 8
13
votes
2 answers

Webpack Module Federation Unsatisfied version 11.x.x of shared singleton module @angular/common (required ^7.2.0)

I am trying to get my rather complicated monolithic app to work with Module Federation. My webpack config looks like that plugins: [ new ModuleFederationPlugin({ remotes: { "mfe1":…
gleixnerp
  • 171
  • 1
  • 2
  • 8
13
votes
1 answer

Issue with Setting Up Webpack and Babel

I have followed every instruction for setting up webpack and babel. I Installed the dependencies with npm install --save-dev webpack webpack-dev-server @babel/core babel-loader @babel/preset-env @babel/polyfill. I also installed the…
Aye
  • 271
  • 3
  • 9
13
votes
2 answers

After build via Webpack 5 app stoped working on Internet Explorer (IE11)

As announced in Webpacks 5.0 release blog post build still works in most browsers after a few minor adjustments in webpack.config.js. But it stopped working in Internet Explorer (11) because the generated output is mixed ES6 and ES5 and therefore…
Bernhard
  • 4,855
  • 5
  • 39
  • 70
13
votes
3 answers

Adding eslint-webpack-plugin into project to provide Typescript linting

I am having a hard time plugging a Typescript linter in my Webpack project. Apparently eslint-loader is deprecated, they give eslint-webpack-plugin as an alternative. Additionally, I am using typescript-eslint/parser instead of tslint (deprecated)…
Ivan
  • 34,531
  • 8
  • 55
  • 100
13
votes
2 answers

How use Bundler Build Feature Flags in Vue 3.0 with Webpack?

Vue 3.0 (now stable) has an undocumented feature Bundler Build Feature Flags: Starting with 3.0.0-rc.3, esm-bundler builds now exposes global feature flags that can be overwritten at compile time: VUE_OPTIONS_API (enable/disable Options API…
ux.engineer
  • 10,082
  • 13
  • 67
  • 112
13
votes
3 answers

How to make create-react-app support .mjs files with webpack?

I'm trying to work with this twitch npm package (https://www.npmjs.com/package/twitch) and am running into some issues when deploying via creat-react-app / react-scripts. From my understanding, the webpack config that is bundled with…
Kyle Pendergast
  • 739
  • 1
  • 8
  • 17
13
votes
6 answers

Looking for help to make npm/pdfjs-dist work with Webpack and Django

I've been trying for a few hours replacing a link-based pdf.js with an npm install of pdfjs-dist, since I noticed that my links were not meant to be used as cdns and could become unstable as described here. I could not find much documentation on how…
Giampaolo Ferradini
  • 529
  • 1
  • 6
  • 17
13
votes
2 answers

How to use sass in VUE application?

I am developing my first application in VUE I have created a styles file at the root of the project and another with the fonts I want to use globally. I'm trying to modify the styles of the components to be able to declare "" and thus be able to use…
homerThinking
  • 785
  • 3
  • 11
  • 28
13
votes
5 answers

nextJS build fails on Vercel because of Webpack errors

Im trying to deploy to Vercel I've done it before with other projects but in this case, the build is failing, it mentions that it doesn't find Footer component, the build works perfectly on local machine. 11:55:14.850 Cloning completed in…
ricardoNava
  • 685
  • 1
  • 7
  • 26
13
votes
1 answer

Why do I need "@babel/plugin-proposal-optional-chaining" in my setup using "@babel/preset-env" and "@babel/preset-typescript"

I have a project using Typescript and @babel/preset-env. Bundling with Webpack fails with this error and the config below. If I un-comment the line, which forces @babel/plugin-proposal-optional-chaining to be included, then compilation works. It…
pipereset
  • 160
  • 1
  • 1
  • 8
13
votes
4 answers

Upgrade to Webpack 5 breaking Storybook 5

In process of upgrading a webpack 4/storybook 5 project to webpack 5 to hopefully take advantage of federated modules. I have regular webpack --config webpack.config.js building working atfer some struggle, but I can't seem to overcome this…
voidzero
  • 564
  • 1
  • 4
  • 11
13
votes
4 answers

Cannot read property 'tapAsync' of undefined at ExternalModuleFactoryPlugin.js:30

I am developing a react project, i thought to setup story book. i am getting the following error and i could not up my storybook(5.3.7) with…
1 2 3
99
100