webpack-plugin

Webpack 4 Plugin: Add module and get result from loader

前提是你 提交于 2021-01-29 10:57:00
问题 I am making a Webpack 4 plugin for fun and to try to understand its internals. The idea is simple: Parse an HTML template file into a tree; Get the asset paths from <img src="..."> and <link href="..."> ; Add the assets to dependencies to load them through the file-loader ; Get the path emitted from file-loader (which might include a hash)and fix the nodes in the tree; Emit the final HTML string into a file. So far, I am stuck at step 4 . Parsing the template and extracting the asset paths

How to write Webpack plugin which adds modules to the bundle on the fly based on other modules?

爱⌒轻易说出口 提交于 2019-12-20 09:46:41
问题 I have a problem with writing a Webpack plugin for a translation service. The goal is to: Get names (and source code) of all required modules during compilation. I need to be able to scan the included source code for special t() function usage but I want to scan only those modules which will be included in the bundle (which, depending on build configuration, can be a subset of all project modules). Based on the gathered modules, I want to create additional modules (with translations) on the

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

↘锁芯ラ 提交于 2019-12-12 10:52:50
问题 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 *TypeError: Cannot read property 'length' of undefined* at node_modules/uglifyjs-webpack-plugin/dist/uglify/index.js:59 this.workers = workers === true ? _os2.default.cpus().length - 1 : Math.min(Number(workers) || 0, _os2.default.cpus().length - 1);

Webpack plugin to modify files after compilation

≡放荡痞女 提交于 2019-12-10 21:53:42
问题 I am writing a Webpack plugin that should replace a part of the JS code with a list of Webpack's generated CSS files. Imaging this JS code: ReactWebComponent.create(<App />, 'react-web-component', { injectReactWebComponent: true }); I want to replace the injectReactWebComponent: true part with injectReactWebComponent: '<link href="static/css/main.cacbacc7.css" rel="stylesheet">' While that link tag is a file generated by Webpack. My (kind of working) code for this goes as follows:

webpack 4 disable uglifyjs-webpack-plugin

对着背影说爱祢 提交于 2019-12-04 10:31:01
问题 I have had this problem for the last 2 days. So I decided to completely disable uglifyjs-webpack-plugin from webpack build process. I was not able to find anything on webpack 4. 回答1: module.exports = { optimization:{ minimize: false, // <---- disables uglify. // minimizer: [new UglifyJsPlugin()] if you want to customize it. } } 来源: https://stackoverflow.com/questions/51263506/webpack-4-disable-uglifyjs-webpack-plugin

Can someone explain Webpack's CommonsChunkPlugin

余生颓废 提交于 2019-12-04 07:22:07
问题 I get the general gist that the CommonsChunkPlugin looks at all the entry points, checks to see if there are common packages/dependencies between them and separates them into their own bundle. So, let's assume I have the following configuration: ... enrty : { entry1 : 'entry1.js', //which has 'jquery' as a dependency entry2 : 'entry2.js', //which has 'jquery as a dependency vendors : [ 'jquery', 'some_jquery_plugin' //which has 'jquery' as a dependency ] }, output: { path: PATHS.build,

webpack 4 disable uglifyjs-webpack-plugin

这一生的挚爱 提交于 2019-12-03 06:07:44
I have had this problem for the last 2 days. So I decided to completely disable uglifyjs-webpack-plugin from webpack build process. I was not able to find anything on webpack 4. module.exports = { optimization:{ minimize: false, // <---- disables uglify. // minimizer: [new UglifyJsPlugin()] if you want to customize it. } } 来源: https://stackoverflow.com/questions/51263506/webpack-4-disable-uglifyjs-webpack-plugin

How to write Webpack plugin which adds modules to the bundle on the fly based on other modules?

北慕城南 提交于 2019-12-02 20:01:18
I have a problem with writing a Webpack plugin for a translation service. The goal is to: Get names (and source code) of all required modules during compilation. I need to be able to scan the included source code for special t() function usage but I want to scan only those modules which will be included in the bundle (which, depending on build configuration, can be a subset of all project modules). Based on the gathered modules, I want to create additional modules (with translations) on the fly and add them to the bundle. Those modules need to be able to import their own dependencies. An