Questions tagged [webpack-plugin]

A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows to load parts for the application on demand. Through "loaders" modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.

132 questions
7
votes
1 answer

How to dynamically add a module/dependency with a webpack plugin?

I feel like what i'm trying to achieve isn't that hard.. but the webpack docs are in a serious disarray and I'm burning many hours on this. How do i inject a "dynamic" module into a webpack build? I want to create this module at build time. For a…
jennas
  • 2,444
  • 2
  • 25
  • 31
7
votes
0 answers

Trigger a WebPack Module rebuild from a plugin

I'm writing a webpack plugin that includes an additional file in the bundle (using child compiler). This works fine, but now I want to add watch support. The problem is, that the included file potentially depends upon all files in the main compiler…
Micha Reiser
  • 201
  • 1
  • 2
  • 6
6
votes
1 answer

Webpack Plugin: run command after assets are written to file system

I've seen this question: Run command after webpack build and I modified the sample code provided there. To describe my scenario, I'm trying to take the assets output by webpack and deploy them to a mounted network drive. I'm using ncp to copy a…
Sean
  • 300
  • 4
  • 12
5
votes
0 answers

Change default Laravel Mix Minimizer/Minifier (webpack)

Is there a way to change the default minifier that Laravel Mix uses? By default, it uses 'Terser' (the Webpack default), but I would like it to instead use Closure Compiler (see here). I have tried various things but have not had any luck yet. This…
5
votes
2 answers

CleanWebpackPlugin config fail when build

I tried to implement a webpack config on a Wordpress theme. I want to add the CleanWebpackPlugin and made a correct install of it. I read a tutorial and I wrote something like this on my webpack.config.js: new…
Owlnado
  • 53
  • 1
  • 4
5
votes
1 answer

Webpack 4 and Uglify Plugin (TypeError: Cannot read property 'length' of undefined)

I'm having problems with Webpack 4 on a Linux machine. The build works fine in dev mode, but fail in production. It also seems to be working on a windows machine. I did try do downgrade webpack to an older version and nothing. Nodejs: v10.2.1 …
yacine benzmane
  • 3,888
  • 4
  • 22
  • 32
5
votes
1 answer

Webpack plugin parser not finding local or module function calls

I'm writing a code analytics webpack plugin that wants to find all instances of a function name in a webpack bundle. I made a repo for this question: https://github.com/RonPenton/webpack-parser-fail-demo So the parser is really simple, just looks…
Ron Penton
  • 1,511
  • 1
  • 12
  • 24
5
votes
1 answer

Webpack plugins - when to call doResolve and when callback?

Every webpack resolve plugin follows the following structure: resolver.plugin(this.source, function(request, callback) { if (something) { resolver.doResolve(target, obj, "aliased with mapping '" + name + "': '" + ...) } else { …
Max Koretskyi
  • 101,079
  • 60
  • 333
  • 488
5
votes
3 answers

Webpack optimize constructors not found

I am testing out webpack and node.js on a windows dev system. I have this script 'webpack.config.js' var debug = process.env.NODE_ENV !== "production"; var webpack = require('webpack'); module.exports = { context: __dirname, devtool: debug ?…
5
votes
0 answers

How to generate a module from a webpack plugin and hot replace it

I’m trying to write a webpack plugin for https://github.com/martinandert/babel-plugin-css-in-js, with the following 2 requirements during development: I don’t want a file to be written to disk, but instead have webpack-dev-server host the file…
alloy
  • 20,908
  • 2
  • 30
  • 40
5
votes
1 answer

ExtractTextPlugin and postCSS - autoprefixer not working

I'm trying to setup webpack to have a compilation pass where it scans all css files in one file tree and then generates a css files with all the styles bundled, autoprefixed and minimised. I can't get autoprefixer plugin to work. Here is the…
Héctor
  • 339
  • 3
  • 18
4
votes
1 answer

Webpack plugin API: getting source maps for a module during parsing

I'm writing a code analyzer. My analyzer uses Webpack's JavaScriptParser hooks. I need to output an error message, but the line number from node.loc is off because a loader has transformed the source code. So I want to feed the error message through…
Benjamin Hodgson
  • 42,952
  • 15
  • 108
  • 157
4
votes
1 answer

How can i get a flat list of file dependencies filtered by entry point from the compilation in webpack 5

I'm trying to update the svg-chunk-webpack-plugin from webpack v4 to v5. The plugin used the compilation object and needs a flat list of file dependencies filtered by entry point to extract all SVGs for each entry points. Example of a nested…
Yoriiis
  • 71
  • 7
4
votes
1 answer

Webpack generate file on build

In my project at work we use Vue with VueI18n for localization. We have one ref.js file which looks like this: export default { project: { lang: { test: { value: 'The test was a success', context: 'This string is a test…
D4rth B4n3
  • 1,268
  • 2
  • 17
  • 26
4
votes
0 answers

How to remove entries in webpack plugin?

I know how to add entry dynamically in webpack plugin, like below: class AddEntryPlugin { apply(compiler) { compiler.plugin('entry-option', () => { compiler.apply(new SingleEntryPlugin(context, request, name)) }) …
Run
  • 876
  • 6
  • 21
1
2
3
8 9