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

webpack ERROR in multi ./src/index.js ./dist/bundle.js

WARNING in configuration The 'mode' option has not been set. Set 'mode' option to 'development' or 'production' to enable defaults for this environment. ERROR in multi ./src/index.js ./dist/bundle.js
look4me
  • 141
  • 1
  • 1
  • 3
14
votes
2 answers

How to prevent webpack to create js file for css?

const path = require('path'); var webpack = require('webpack'), ExtractTextPlugin = require("extract-text-webpack-plugin"); var nodeExternals = require('webpack-node-externals'); const CssEntryPlugin =…
Trupti
  • 843
  • 2
  • 11
  • 28
14
votes
2 answers

What's the replacement for webpack-dev-server in Webpack 4?

I've noticed that installing webpack-dev-server@webpack/webpack#next actually installs webpack (without any warning). However, there's no webpack-dev-server executable any more. Is there a replacement for this in Webpack 4, or do I need a separate…
Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404
14
votes
2 answers

Visual Studio -> Shared TypeScript Library -> TS6059 File '' is not under 'rootDir' ''. 'rootDir' is expected to contain all source files

We are using Visual Studio 2017 and have two separate web projects that are supposed to share some React components written in TypeScript. There can also be shared JavaScript files and CSS files. For this we have created a Shared Project in Visual…
Ogglas
  • 62,132
  • 37
  • 328
  • 418
14
votes
6 answers

How to import ipcRenderer in react?

I've tried to import ipcRenderer in react app import {ipcRenderer} from 'electron'; but I get this error message : require is not defined
Vito
  • 320
  • 1
  • 3
  • 11
14
votes
1 answer

How to properly Webpack library export?

First real foray into using webpack, and I'm trying to create a reusable library. I can't figure out how to properly export my library classes. Here's a general rundown of what I'm currently doing, and how I'm trying to use what's been built. I have…
Steve -Cutter- Blades
  • 5,057
  • 2
  • 26
  • 40
14
votes
1 answer

Webpack ProvidePlugin global variable (Cannot find module)

I'm pretty new to Webpack, but can't figure out why my ProvidePlugin call is not working as expected. I have the following file: App.js var App = function() { getSomething: function(size) {} }(); module.exports = App; I want this 'App'…
Dennis de Laat
  • 513
  • 1
  • 5
  • 10
14
votes
3 answers

Is it possible to generate Typescript interfaces from files with a webpack loader?

I am attempting to create a webpack loader that converts a file containing a description of API data structures into a set of TypeScript interfaces. In my concrete case, the file is JSON, but this should be ultimately irrelevant — the file is only a…
Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
14
votes
2 answers

Import raw files from typescript with webpack using the `import` statement

I need to import raw data from typescript using webpack. Here is my setup: $ tree . +-- file.txt +-- main.ts +-- package.json +-- tsconfig.json +-- webpack.config.js file.txt file-content main.js import file from…
Luke Skywalker
  • 1,464
  • 3
  • 17
  • 35
14
votes
1 answer

__non_webpack_require__ is not defined

I am new to webpack and node, and I am wondering how to use the __non_webpack_require__ function. I've visited webpack's website but am still confused as to what this function is and how I can use it. Could you provide a short description of a…
Mark
  • 9,718
  • 6
  • 29
  • 47
14
votes
3 answers

SCSS-compiler alternatives to LibSass for a node app

Libsass seems to be one of the most popular compilers for SCSS and http://sass-lang.com/libsass lists a wide variety of libsass wrappers for many common programming languages. For a node-app, node-sass and the corresponding loaders for webpack or…
Oblomov
  • 8,953
  • 22
  • 60
  • 106
14
votes
4 answers

Build webpack-typescript library for use in other webpack-typescript project with npm

How do I create a typescript library with Webpack that I can use in another typescript project managed by Webpack? With an ES6 project, I can leave all files as ES6 in the library, and in my client application webpack compiles my library into ES5…
Stefan Kendall
  • 66,414
  • 68
  • 253
  • 406
14
votes
2 answers

Is there any way to convert webpack bundled js file into source code ts?

Is there any way to convert webpack bundled js file into source code ts? I have bundle.js file with me bundled with webpack. Unfortunately the source code files are deleted by a stupid accident. I want to reverse engineer my bundle.js file to get…
Nutan
  • 1,478
  • 3
  • 12
  • 19
14
votes
0 answers

Angular CLI Hot Module Reload

I followed this github story: https://github.com/angular/angular-cli/wiki/stories-configure-hmr I am able to see changes after auto-refresh when I do ng serve (environment is Dev), however with ng serve --hmr -e=hmr, the page auto refreshes (like a…
Moshe
  • 2,583
  • 4
  • 27
  • 70
14
votes
2 answers

React + Reactstrap + CSS Modules + Webpack

I've been looking how I can combine the following : ReactJS + ReactStrap and CSS-Modules (react-css-modules and/or boostrap-css-modules), however, I can't seem to piece the three modules together to achieve the desired effect (or find any help…
teh0wner
  • 1,393
  • 6
  • 16
  • 33