webpack-4

How to generate dynamic import chunk name in webpack

守給你的承諾、 提交于 2019-12-02 20:55:16
I am dynamically calling an import statement in my typescript code, based on that webpack will create chunks like below: you can see Webpack is automatically generating the file name as 1,2,3 respectively, the name is not a friendly name I have tried a way to provide the chunk name through comment, but it's generating modulename1.bundle.js , modulename2.bundle.js bootStrapApps(config) { config.apps.forEach(element => { registerApplication( // Name of our single-spa application element.name, // Our loading function () => import(/* webpackChunkName: "modulename"*/ "../../" + config.rootfolder +

Webpack 4, Vue using Typescript classes and JS code at the same time.

人盡茶涼 提交于 2019-12-02 04:29:06
I am migrating JS files to Typescript and my goal is, to be able to use both JS and Typescript classes in Vue. I know, I can convert Vue scripts into Typescript, but I don't want to do it right now. The problem arises in a component.vue file: this.exceptionHandler = app.resolve('ExceptionHandler'); The errror I get in the browser's console is this (compilation is ok): "TypeError: Cannot call a class as a function" ExceptionHandler is defined in a TypeScript .ts file. The question is: Is it possible to first transpile the TS code to JS ES6, then put the code together and then run Babel on

Load video mp4 webpack loader

旧时模样 提交于 2019-12-02 01:34:06
How to use loader for mp4 video format with webpcak 4, I try like this: { test: /\.mp4$/, use: 'file-loader', loader: 'file-loader?name=videos/[name].[ext]', }, and import like this import pressButtonAnimated from './images/pressButtonAnimated.mp4' But it does not work for me, and I get an error You may need an appropriate loader to handle this file type. But this one is work for me, but I don wanna add in each file import pressButtonAnimated from '-!file-loader!./images/pressButtonAnimated.mp4' The way how you declare your loader is not right. You are mixing two ways to define loaders. { test

Can't import SVG into Next JS?

∥☆過路亽.° 提交于 2019-12-01 05:25:55
When I try to import SVG Image then the following error shows. Which loader I have to use for importing SVG images? ./static/Rolling-1s-200px.svg 1:0 Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type. > <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2000 2000"><filter id="b"><feGaussianBlur stdDeviation="12" /></filter><path fill="#817c70" d="M0 0h2000v2000H0z"/><g filter="url(#b)" transform="translate(4 4) scale(7.8125)" fill-opacity=".5"><ellipse fill="#000210" rx="1" ry="1" transform="matrix(50.41098 -3.7951 11.14787 148.07886 107

Webpack 4 - Sourcemaps

北城余情 提交于 2019-12-01 03:07:00
This article webpack 4: mode and optimization seems to suggest that when mode is set to development the devtool is set to eval . I was expecting this to trigger sourcemap generation but running the webpack-4-quickstart in either development or production mode results in no sourcemaps being generated. How can I generate sourcemaps with webpack 4? I think what you are expecting is extracted file including source maps like 'bundle.js.map', but eval type doesn't generate separate file: eval - Each module is executed with eval() and //@ sourceURL. This is pretty fast. The main disadvantage is that

Can't import SVG into Next JS?

China☆狼群 提交于 2019-12-01 01:32:35
问题 When I try to import SVG Image then the following error shows. Which loader I have to use for importing SVG images? ./static/Rolling-1s-200px.svg 1:0 Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type. > <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2000 2000"><filter id="b"><feGaussianBlur stdDeviation="12" /></filter><path fill="#817c70" d="M0 0h2000v2000H0z"/><g filter="url(#b)" transform="translate(4 4) scale(7.8125)" fill

[Vue warn]: Failed to mount component: template or render function not defined in Webpack 4

与世无争的帅哥 提交于 2019-11-30 17:29:49
问题 I started getting this error once I upgraded to Webpack and related dependencies to v4: [Vue warn]: Failed to mount component: template or render function not defined. Here's the relevant snippets of my package.json and webpack.config.js before and after: Before upgrade: package.json { "dependencies": { "vue": "^2.5.0", "vue-template-compiler": "^2.5.0" }, "devDependencies": { "babel-core": "^6.9.0", "babel-loader": "^6.2.4", "babel-plugin-external-helpers": "^6.22.0", "babel-plugin-transform

Webpack 4 : ERROR in Entry module not found: Error: Can't resolve './src'

社会主义新天地 提交于 2019-11-30 14:33:40
问题 I was trying to run webpack-4 first time webpack ./src/js/app.js ./dist/app.bundle.js it shows warning / error : WARNING in configuration The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment. You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/concepts/mode/ ERROR in multi ./src/js/app.js ./dist/app.bundle.js Module not

Webpack 4 universal library target

柔情痞子 提交于 2019-11-30 11:05:53
According to the Webpack 4 documentation , if I specify libraryTarget: 'umd' it should result in the following output: (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["MyLibrary"] = factory(); else root["MyLibrary"] = factory(); })(typeof self !== 'undefined' ? self : this, function() { return _entry_return_; }); However, what I get is: (function

How to use Webpack 4 SplitChunksPlugin with HtmlWebpackPlugin for Multiple Page Application?

寵の児 提交于 2019-11-30 10:58:31
问题 I'm trying to utilize the SplitChunksPlugin to produce separate bundles per each page/template in a MPA. When I use the HtmlWebpackPlugin, I get an html file for each page with a script tag pointing to the correct bundle. That is great! However, the trouble I'm having is with my vendor files. I want separate html files to point to only the vendor bundles they need. I can't get each separate html file to point to the correct vendor bundles when the SplitChunksPlugin creates multiple vendor