Webpack

Cannot read property 'Component' of undefined - webpack build of react component plugin

Deadly 提交于 2020-12-09 05:14:24
问题 I'm building a react-leaflet wrapper for my leaflet plugin leaflet-arrowheads. Its a component that I want people to be able to install as an npm package, import, and use. The component is simple: import React from 'react' import { Polyline } from 'react-leaflet' import 'leaflet-arrowheads' class ArrowheadsPolyline extends React.Component{ componentDidMount(){ const polyline = this.polylineRef.leafletElement if (this.props.arrowheads){ polyline.arrowheads(this.props.arrowheads) polyline.

Cannot read property 'Component' of undefined - webpack build of react component plugin

余生长醉 提交于 2020-12-09 05:13:09
问题 I'm building a react-leaflet wrapper for my leaflet plugin leaflet-arrowheads. Its a component that I want people to be able to install as an npm package, import, and use. The component is simple: import React from 'react' import { Polyline } from 'react-leaflet' import 'leaflet-arrowheads' class ArrowheadsPolyline extends React.Component{ componentDidMount(){ const polyline = this.polylineRef.leafletElement if (this.props.arrowheads){ polyline.arrowheads(this.props.arrowheads) polyline.

【经验】基于Quick BI的前端性能调优技巧

夙愿已清 提交于 2020-12-08 20:09:38
欢迎关注“ 数智化转型俱乐部 ”! 摘要 基于对Quick BI历年架构变迁中性能的排查、解决和总结,本文不从常规的性能优化 方式去描述,而将尝试结合项目的“个性”,总结整个前端层面相对“共性”的问题,从而提供一些前端性能解法方面的思路,帮助解决和避免前端性能问题。 随着前端的范畴逐渐扩大,深度逐渐下沉,富前端必然带来的一个问题就是性能。 特别是在大型复杂项目中,重 前端业务可能因为一个小小的数据依赖,导致整个页面卡顿甚至崩溃的问题,基于对Quick BI历年架构变迁中性能的排查、解决和总结,本文不从常规的性能优化 方式去描述,而将尝试结合项目的“个性”,总结整个前端层面相对“共性”的问题,从而提供一些前端性能解法方面的思路,帮助解决和避免前端性能问题。 1 引发性能问题原因? 引发性能问题的原因通常不是单方面缘由,特别是大型系统迭代多年后,长期积劳成疾造成,所以我们要必要分析找到症结所在,并按瓶颈优先级逐个击破,拿我们项目为例,大概分几个方面: 1、资源包过大 通过Chrome DevTools的Network标签,我们可以拿到页面实际拉取的资源大小(如下图) 经过前端高速发展,近几年项目更新迭代,前端构建产物也在急剧增大,因为要业务先行,很多同学引入库和编码过程并没有考虑性能问题,导致构建的包增至几十MB,这样带来两个显著的问题: 弱(普通)网络下,首屏资源下载耗时长

Storybook: Failed to execute 'createElement' on svg files using @svgr/webpack

前提是你 提交于 2020-12-08 06:19:10
问题 My error in the first place is exactly the same as the one described here. I'm using the @svgr/webpack package to import my .svg files as a React component like that: import Shop from './icons/shop.svg' return <Shop /> It works fine on my app but when I tried to do the same in Storybook I get this error: Failed to execute 'createElement' on 'Document': The tag name provided ('static/media/shop.61b51e05.svg') is not a valid name. So I added the loader into my .storybook/main.js file to extends

Storybook: Failed to execute 'createElement' on svg files using @svgr/webpack

时间秒杀一切 提交于 2020-12-08 06:18:56
问题 My error in the first place is exactly the same as the one described here. I'm using the @svgr/webpack package to import my .svg files as a React component like that: import Shop from './icons/shop.svg' return <Shop /> It works fine on my app but when I tried to do the same in Storybook I get this error: Failed to execute 'createElement' on 'Document': The tag name provided ('static/media/shop.61b51e05.svg') is not a valid name. So I added the loader into my .storybook/main.js file to extends

Storybook: Failed to execute 'createElement' on svg files using @svgr/webpack

我只是一个虾纸丫 提交于 2020-12-08 06:18:51
问题 My error in the first place is exactly the same as the one described here. I'm using the @svgr/webpack package to import my .svg files as a React component like that: import Shop from './icons/shop.svg' return <Shop /> It works fine on my app but when I tried to do the same in Storybook I get this error: Failed to execute 'createElement' on 'Document': The tag name provided ('static/media/shop.61b51e05.svg') is not a valid name. So I added the loader into my .storybook/main.js file to extends

webpack 4 gives background: url([object Module]) as bg image

霸气de小男生 提交于 2020-12-08 06:07:27
问题 I'm having issues with setting up web-pack 4 and svg-sprite-loader to render svg icons as background images. I was following these instructions from official docs for svg-sprite-loader (https://github.com/kisenka/svg-sprite-loader/tree/master/examples/extract-mode). I have successfully managed to create sprite.svg file in my dist folder and use it as reference for my use tags inside of html. However, i was also trying to use svg icons from my src/images/icons folder for a background image

webpack 4 gives background: url([object Module]) as bg image

早过忘川 提交于 2020-12-08 06:05:08
问题 I'm having issues with setting up web-pack 4 and svg-sprite-loader to render svg icons as background images. I was following these instructions from official docs for svg-sprite-loader (https://github.com/kisenka/svg-sprite-loader/tree/master/examples/extract-mode). I have successfully managed to create sprite.svg file in my dist folder and use it as reference for my use tags inside of html. However, i was also trying to use svg icons from my src/images/icons folder for a background image

Nuxt: Include 3rd party library in Vue Page component

人盡茶涼 提交于 2020-12-07 15:08:26
问题 Imagine you want to include a 3rd party js library (eg Three.js) in a Vue page, via Nuxt. Local sources in the head section of either nuxt.config.js or YourPage.vue do not work: head: { script: [ { src: '~assets/lib/three.min.js' } ] } The above just results in a 404 http://yoursite/~assets/lib/three.min.js NOT FOUND . In your page component, you can specify a remote src: head: { script: [ { src: 'https://cdnjs.cloudflare.com/ajax/libs/three.js/85/three.min.js' } ] } But there's seemingly no

Nuxt: Include 3rd party library in Vue Page component

…衆ロ難τιáo~ 提交于 2020-12-07 15:05:31
问题 Imagine you want to include a 3rd party js library (eg Three.js) in a Vue page, via Nuxt. Local sources in the head section of either nuxt.config.js or YourPage.vue do not work: head: { script: [ { src: '~assets/lib/three.min.js' } ] } The above just results in a 404 http://yoursite/~assets/lib/three.min.js NOT FOUND . In your page component, you can specify a remote src: head: { script: [ { src: 'https://cdnjs.cloudflare.com/ajax/libs/three.js/85/three.min.js' } ] } But there's seemingly no