Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is output.crossOriginLoading for in webpack's config?

Tags:

webpack

output.crossOriginLoading,if I set it to true in the configuration,then what will be different in the compiled bundle?Is it some code for JSONP will be added?And you can use another computer to debug the web by connecting to the webpack-dev-server?

like image 981
zzzgoo Avatar asked Mar 02 '17 09:03

zzzgoo


People also ask

What is entry and output in webpack?

The output in Webpack is an object holding the path where our bundles and assets will go, as well as the name the entries will adopt. var path = require('path'); var baseConfig = { entry: { main: './src/index.js' }, output: { filename: 'main.js', path: path. resolve('./build') } }; // export configuration module.

Where does webpack output go?

Webpack will generate the files and put them in the /dist folder for you, but it doesn't keep track of which files are actually in use by your project. In general it's good practice to clean the /dist folder before each build, so that only used files will be generated. Let's take care of that with output.

Why do we need Webpacks?

This is why webpack exists. It's a tool that lets you bundle your JavaScript applications (supporting both ESM and CommonJS), and it can be extended to support many different assets such as images, fonts and stylesheets.

What is libraryTarget in webpack?

This is according to their documentation: "libraryTarget: "umd" - This exposes your library under all the module definitions, allowing it to work with CommonJS, AMD and as global variable." Also, I built the exact same code with Webpack 3 and it produced a proper bundle.


1 Answers

Webpack chunks are included in a running application by injecting on the fly the page with <script> tags.

Some HTML elements like <script> tags provide support for crossorigin attribute to cover those scenarios where a Cross-Origin Resource Sharing configuration is needed. (eg linked files loaded from a different domain).

Webpack's output.crossOriginLoading setting is meant to configure the crossorigin attribute of such generated <script> elements.

like image 170
Andrea Carraro Avatar answered Oct 25 '22 04:10

Andrea Carraro