webpack-3

Webpack - How to load non module scripts into global scope | window

眉间皱痕 提交于 2019-11-28 08:36:34
so i have a few vendor files that i need to run from window scoped (it's a bunch of window scoped functions) plus i have some polyfills that i would like to bundle into the vendor bundle as well. So i tried something like this: new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'js/vendor.min.js', minChunks: Infinity, }) entry: { 'vendor' : ['./vendor.js', './vendor2.js', './polyfills.js'] } Now when i run my webpack build it does generate my vendor bundle but it's all wrapped in a webpackJsonP wrapper so the functions are not accesible on the window scope. I've also looked at

Webpack 4 migration CommonsChunkPlugin

爱⌒轻易说出口 提交于 2019-11-27 11:47:28
I need help migrating the following code from webpack 3 to 4. new webpack.optimize.CommonsChunkPlugin({ minChunks: module => module.context && module.context.indexOf("node_modules") !== -1, name: "vendor", chunks: ["main"] }) I have two entry files and want only the dependencies of the first one to be included in the vendor chunk. The dependencies of the second entry should all stay in its own bundle. Legends As of webpack v4 the CommonsChunkPlugin is deprecated. We have deprecated and removed CommonsChunkPlugin, and have replaced it with a set of defaults and easily overridable API called

Webpack 4 migration CommonsChunkPlugin

℡╲_俬逩灬. 提交于 2019-11-26 22:20:50
问题 I need help migrating the following code from webpack 3 to 4. new webpack.optimize.CommonsChunkPlugin({ minChunks: module => module.context && module.context.indexOf("node_modules") !== -1, name: "vendor", chunks: ["main"] }) I have two entry files and want only the dependencies of the first one to be included in the vendor chunk. The dependencies of the second entry should all stay in its own bundle. 回答1: As of webpack v4 the CommonsChunkPlugin is deprecated. We have deprecated and removed

Define global variable with webpack

▼魔方 西西 提交于 2019-11-25 23:46:25
问题 Is it possible to define a global variable with webpack to result something like this: var myvar = {}; All of the examples I saw were using external file require(\"imports?$=jquery!./file.js\") 回答1: There are several way to approach globals: 1) Put your variables in a module. Webpack evaluates modules only once, so your instance remains global and carries changes through from module to module. So if you create something like a globals.js and export an object of all your globals then you can