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
14
votes
2 answers

Symfony Webpack: Could not find the entrypoints file from Webpack

A relatively fresh Symfony 4.1.7 project after installing Webpack Encore throws the error An exception has been thrown during the rendering of a template ("Could not find the entrypoints file from Webpack: the file …
geoB
  • 4,578
  • 5
  • 37
  • 70
14
votes
2 answers

webpack Invalid Host header when accessing from domain, not when through IP

I have setup a domain name to my server which I have been accessing through the IP for awhile, but now I am trying to access it through the domain name. When I view it from the IP my react app works fine, however when I try through the domain it…
Dylan Cross
  • 5,918
  • 22
  • 77
  • 118
14
votes
1 answer

Transpiling Array.prototype.flat away with @babel?

I inadvertently introduced a backwards compatibility issue in my React app by using Array.prototype.flat. I was very surprised this didn't get resolved by transpiling - I thought this would result in es2015 compatible code. How can I get Babel 7 to…
DerKastellan
  • 143
  • 2
  • 7
14
votes
1 answer

Module parse failed: Unexpected token

Hey Getting the error below I run the webpack command: $> webpack --mode "development" stack trace: Version: webpack 4.17.2 Time: 1357ms Built at: 09/10/2018 8:13:26 PM Asset Size Chunks Chunk Names bundle.js 1.37 MiB main…
Anthony
  • 1,651
  • 1
  • 17
  • 31
14
votes
2 answers

how to load React app / Lib inside ExtJs Component

We are using Extjs 3.1 and we are trying to integrate reactjs into. we have vendor library which has react, reacr-dom, redux and other libs are packed and included as script. Here is my extjs code var CompositeViewer = Ext.extend(Ext.BoxComponent,…
Nnp
  • 1,813
  • 7
  • 36
  • 62
14
votes
1 answer

How to make a class-based custom element side-effect-free so webpack only bundles the explicitly imported components

I have a set of spec v1 custom elements which I'm using webpack 4 to bundle (and babel-loader to transpile). The components all look similar to this: export class CompDiv extends HTMLDivElement { constructor(...args) { const self =…
connexo
  • 53,704
  • 14
  • 91
  • 128
14
votes
2 answers

Aliasing with Webpack 4 and awesome-typescript loader not working

I'm currently having issue getting aliasing to work properly. From my understanding, to get aliasing to work properly with webpack you have to: Versions "typescript": "2.8.3", "webpack": "4.16.2", "webpack-cli": "3.1.0", …
darewreck
  • 2,576
  • 5
  • 42
  • 67
14
votes
2 answers

Are there any pros to replace Webpack with Parcel when using Angular 4+ version?

I'm wondering is there any solid reason I should replace Webpack with Parcel in Angular 4+ versions? I mean there are a lot of configuration from the Angular team which are specific for Webpack and I'm wondering is it worth it? Will there be any…
Marin Takanov
  • 1,079
  • 3
  • 19
  • 36
14
votes
2 answers

React Webpack 4 Resolve Alias

I'm having difficulty getting resolve alias to work in my React app using WebPack, and everything I've tried from google results don't seem to make a difference. Here is my resolve from webpack. C:\website\webpack.config.js resolve: { …
Richard Whitehouse
  • 679
  • 3
  • 14
  • 28
14
votes
2 answers

TypeError: Cannot read property 'babel' of undefined

Following is my package json file. I have installed node_modules successfully. But Getting the error: "TypeError: Cannot read property 'babel' of undefined" while running "webpack --watch". Please let me know if anyone is aware of this. "axios":…
Abhilasha
  • 1,177
  • 4
  • 10
  • 17
14
votes
5 answers

Callback was already called angular cli

I updated my angular-cli then i got error in ng serve Callback was already called. at throwError (node_modules\neo-async\async.js:14:11) at node_modules\neo-async\async.js:2805:7 at _combinedTickCallback (internal/process/next_tick.js:131:7) at…
Aya Abdelaziz
  • 355
  • 3
  • 10
  • 23
14
votes
2 answers

webpack fails "module build failed: unknown word" with webpack.config.js file

webpack does not work for me when trying to add css using the css-loader. os: Windows 10 pro, webpack: 4.8.0 node: 8.9.4 npm: 6.0.0 css-loader: 0.28.11 style-loader: 0.21.0 package.json { "name": "webpack-dev", "version": "1.0.0", …
rochin
  • 141
  • 1
  • 1
  • 5
14
votes
2 answers

SVG loading vue-svg-loader; [Vue warn]: Invalid Component definition

If I want to use vue-svg-loader in an existing vue-cli application, I get the error message [Vue warn]: Invalid Component definition: /img/logout.b0c3dfb7.svg Following Steps are already done: 1) Install vue-svg-loader as devDependency 2) Add…
user3025289
14
votes
3 answers

Webpack 4 with sass-loader & resolve-url-loader - Image paths not being found

Minimally reproducible setup here: https://github.com/jamesopti/webpack_playground/tree/resolve_url_loader_issue Im trying to use resolve-url-loader to add a hashname to my scss url() image paths, but I'm having a heck of a time getting it to work…
jamis0n
  • 3,610
  • 8
  • 34
  • 50
14
votes
2 answers

Module not found: Error: Can't resolve 'bundle.js' in '/Users/jonathankuhl/Documents/Programming/node js/sandbox/webpack-app'

I am trying to go through a very basic tutorial about Webpack. I cannot get it to compile a very basic single line javascript application. I have installed and uninstalled it multiple times. It's just a tutorial to learn how to use Webpack. I…
Jonathan Kuhl
  • 699
  • 9
  • 23