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
6 answers

Console logging error on bundle.js instead of React component

I have created a Webpack build which works fine for me - it has a dev-server which I use for hot-reloading, and a production express server that runs a template html file and integrates the bundle.js file. This is all great, except when I'm working…
Paulos3000
  • 3,355
  • 10
  • 35
  • 68
14
votes
5 answers

html-webpack-plugin: How to inject parameters like title into the template

I am trying to pass title to html-webpack-plugin but it does not create title tag at all :( Can somebody show me where is the problem webpack.js var HtmlWebpackPlugin = require('html-webpack-plugin'); var webpack =…
Miomir Dancevic
  • 6,726
  • 15
  • 74
  • 142
14
votes
4 answers

How to get webpack and iis express to work together?

I have Angular 2 and Webpack 2 starter which run on node by webpack-dev-server, and I what to run it from visual studio with web-api. The problem is when angular2-webpack-starter run webpack-dev-server on port 3000. and IIS Express run on different…
Shlomi Levi
  • 3,114
  • 1
  • 23
  • 35
14
votes
2 answers

React typescript typings not working

After installing via typings I get the below error in terminal Terminal error error TS2320: Interface 'Element' cannot simultaneously extend types 'ReactElement' and 'ReactElement'. Named property 'type' of types 'ReactElement' and…
Ajain Vivek
  • 1,111
  • 1
  • 12
  • 20
14
votes
1 answer

Example of setting webpack public path at runtime

I am struggling to find an example of how to set the public path of an output file of a webpack bundle. The documentation says: If you don't know the publicPath while compiling, you can omit it and set __webpack_public_path__ on your entry…
CLJ
  • 1,907
  • 5
  • 22
  • 36
14
votes
1 answer

How to pass the build hash as an environment variable in webpack?

I've got an internal application that's built using webpack that gets deployed frequently. In order to make bug reporting easier, I want to include an environment variable of the build hash [hash] that webpack adds to bundle names. This would let me…
Soviut
  • 88,194
  • 49
  • 192
  • 260
14
votes
2 answers

Can't find bundle.js

I know this question has been asked before, but I honestly can't find the answer anywhere-- it appears as if I'm doing everything I should however bundle is not created. So I have this webpack.config.js file that's supposed to handle HMR + React,…
Jay
  • 998
  • 1
  • 10
  • 22
14
votes
2 answers

How to disable bundling in Webpack for development?

In my web app I was using RequireJS to asynchronously load my javascript files on demand. This worked well for dev - when debugging my app I could see which script is dependent on which and order in which they were loaded. This simplified…
14
votes
2 answers

webpack-dev-server: how to get error line numbers of orignal files

With webpack-dev-server running it seems that all errors in the output are pointing to line numbers in the bundle.js and not the original source file. How do I get line numbers of the original source files? I'm using webpack with babel for ES2015…
Steffen
  • 3,327
  • 2
  • 26
  • 30
14
votes
3 answers

Error using component done with react,redux and react-redux and build with webpack in react application

I have done a component with a store using react, redux and react-redux. bundling of the code is done with webpack.(please check the codes attached below) when i wanted to use the webpack build component inside another react project i faced the…
Rangana Sampath
  • 1,447
  • 3
  • 32
  • 57
14
votes
1 answer

Chrome not requesting JS source map, but Firefox does

I'm using webpack to build my client JS with the devtool: 'source-map' option, so my JS bundle ends in //# sourceMappingURL=app.bundle.js.map. When I open chrome devtools, Chrome shows a "Source Map detected" banner but does not actually show the…
14
votes
2 answers

WebPack execute function before build starts

I need to execute one JavaScript function before the Webpack starts its building process. The function just takes .scss files and concatenate them into one. After that Webpack should take the result file. Is there an option to do that? At the…
Amay
  • 1,461
  • 5
  • 27
  • 56
14
votes
2 answers

Missing sourcemaps in Typescript + Webpack project

I've created a Github repo that has all the source code related to this question. I'm able to load build/index.html in the browser after running npm install. However, when I view the sources tab in Chrome, I don't see the source maps associated with…
wmock
  • 5,382
  • 4
  • 40
  • 62
14
votes
5 answers

How To Use ScrollMagic with GSAP and Webpack

In order to use ScrollMagic with GSAP, you need to load the animation.gsap.js plugin. With Webpack you would do something like this to accomplish that (assuming you use the CommonJS syntax and installed everything with npm): var TweenMax =…
medoingthings
  • 2,985
  • 3
  • 17
  • 17
14
votes
3 answers

React + Webpack character encoding issues

I'm currently making a website using ReactJS and webpack to build it. My text editor is set on ISO-8859-15 encoding and I'm using accented or special chars like é è à ç. In my html page, I believe I'm using the right configuration:
pistou
  • 2,799
  • 5
  • 33
  • 60