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

Angular 4 : Build to prod: Property is private and only accessible within class

i'm using Angular 4 , i'm running : ng build --prod i'm catching this : ng build --prod Your global Angular CLI version (1.2.2) is greater than your local version (1.0.0). The local Angular CLI version is used. To disable this warning use "ng set…
firasKoubaa
  • 6,439
  • 25
  • 79
  • 148
14
votes
3 answers

jQuery UI $(...).sortable is not a function with WebPack

I believe I've set everything up correctly, but I'm getting an odd issue with Webpack. Consider this simple app.ts file: 'use strict'; import $ = require('jquery'); import 'jquery-ui'; $(function() { $( "#sortable"…
Chuck Le Butt
  • 47,570
  • 62
  • 203
  • 289
14
votes
2 answers

istanbul-instrumenter-loader: coverage issues don't match source

I'm using istanbul-instrumenter-loader to try to generate code coverage reports for my untranspiled es6 code, and while everything runs fine, the issues reported in the generated HTML output doesn't seem to line up with the actual source. For…
tacospice
  • 647
  • 5
  • 20
14
votes
3 answers

I get following error when I import *.vue files without .vue extension?

I get following error when I import a vue file without .vue extension . ERROR in ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./src/App.vue Module not found: Error: Can't resolve './components/Navbar' My web back…
CuriousGuy
  • 3,818
  • 4
  • 24
  • 28
14
votes
3 answers

Proxyquire with webpack don't compile

I have installed proxyquire and my ajax.test.tsx file contains the following code, just 2 lines import * as proxyquire from 'proxyquire'; proxyquire.noCallThru(); My webpack code is the following module.exports = { entry: { …
hendrixchord
  • 4,662
  • 4
  • 25
  • 39
14
votes
3 answers

Configuration for create-react-app after ejecting to build a component library

I started to build a component library that I want to publish on NPM (and reuse in other apps) by creating a React app using create-react-app. Unfortunately the create-react-app default configuration doesn't seem to support building such component…
medihack
  • 16,045
  • 21
  • 90
  • 134
14
votes
2 answers

How to bundle and copy CSS files from source folder to dist folder?

Here is my folder structure: I want to minify and bundle the CSS files inside my src/css folder and output it as a single CSS file inside dist. All the examples I've seen so far recommend require-ing the CSS file inside a JS file. I do not want…
Saravana
  • 37,852
  • 18
  • 100
  • 108
14
votes
3 answers

Ignoring files with Webpack Dev Server

I am using Emacs to edit the files in directories watched by Webpack's development server. Every time I make a change in a file, a backup file gets created in the same directory, like .#original_filename, even though I did not save the changes in…
osolmaz
  • 1,873
  • 2
  • 24
  • 41
14
votes
4 answers

Initial static React HTML rendering with Webpack

Is there a way to pre-generate the HTML structure of a (single route) React application directly in the HTML entry point? Then the page will be able to display HTML (based on React initial state) before any JS is loaded. I'm actually using…
Yves M.
  • 29,855
  • 23
  • 108
  • 144
14
votes
1 answer

Laravel Mix disable file loader for url()

Laravel 5.4 introduced laravel mix with webpack. There is no clear documentation for working with images in laravel mix(like, how it works and to customize it for our needs). Since it is not working as I expected, I would like to disable it for my…
Shankar Prakash G
  • 1,099
  • 18
  • 34
14
votes
3 answers

Where is the webpack.config.js in angular-cli new project?

I'm looking into webpack and also angular-cli, and even though angular-cli is supposed to use webpack, I can't see any webpack.config.js file when I create a new project with ng new Does anybody know how does this work in angular-cli?
David
  • 3,364
  • 10
  • 41
  • 84
14
votes
4 answers

Flow module not found with .scss file

I have a file using scss with css-modules like so: import styles from './Login.scss'; The webpack build works fine but i'm getting a flow error: Required Module Not Found In my .flowconfig I have…
john_ryan
  • 1,557
  • 1
  • 16
  • 34
14
votes
1 answer

Webpack warning entrypoint size limit bundle.js

Issue In my Angular2 node application this warning appears without making any changes to my application, Warning WARNING in asset size limit: The following asset(s) exceed the recommended size limit (250 kB). This can impact web performance. …
wuno
  • 9,547
  • 19
  • 96
  • 180
14
votes
2 answers

MSBuild and Webpack

I am developing an Angular2 application in VS2015 and have a webpack bundling and minification environment set up for the same. This is my webpack.conf.js switch (process.env.NODE_ENV) { case 'prod': case 'production': …
lohiarahul
  • 1,432
  • 3
  • 22
  • 35
14
votes
4 answers

Webpack check file exist and import in condition

I use webpack in my react project. I want check file in 'foo/myfile' and if that file exist import in my component, or load from 'bar/myfile'. for example: let myModule; if(webpackCheckFileExist('foo/myfile.jsx')){ myModule =…
nDiviD
  • 444
  • 1
  • 4
  • 11