Webpack

Webpack SASS-loader include statement breaks SASS @import statemetns

我与影子孤独终老i 提交于 2021-02-07 20:45:31
问题 So for background originally I was excluding the node_modules directory in my Webpack config, which was working fine for my sass @import statements, but made it very difficult to include things from the node_modules directory. So I switched the SASS loader to the following { test: /\.scss$/, include: [path.resolve(__dirname, "/src/client"), path.resolve(__dirname, "/node_modules/angular-material/")], loader: 'style-loader!css-loader!autoprefixer-loader!sass-loader' }, Please also note I tried

Webpack SASS-loader include statement breaks SASS @import statemetns

僤鯓⒐⒋嵵緔 提交于 2021-02-07 20:43:35
问题 So for background originally I was excluding the node_modules directory in my Webpack config, which was working fine for my sass @import statements, but made it very difficult to include things from the node_modules directory. So I switched the SASS loader to the following { test: /\.scss$/, include: [path.resolve(__dirname, "/src/client"), path.resolve(__dirname, "/node_modules/angular-material/")], loader: 'style-loader!css-loader!autoprefixer-loader!sass-loader' }, Please also note I tried

Cannot use React.lazy with Material UI icons

旧城冷巷雨未停 提交于 2021-02-07 20:35:04
问题 as I have quite a lot of icons in many places in my app, I want to use code splitting for them. I have created helper component to do that: import React, { FunctionComponent, Suspense } from 'react'; interface LazyMuiIconProps { name: string; } export const LazyMuiIcon: FunctionComponent<LazyMuiIconProps> = ({ name }) => { console.log(name); const IconElement = React.lazy(() => import(`@material-ui/icons/${name}`)); // const IconElement = React.lazy(() => import(`@material-ui/icons/Home`));

Cannot use React.lazy with Material UI icons

泄露秘密 提交于 2021-02-07 20:32:53
问题 as I have quite a lot of icons in many places in my app, I want to use code splitting for them. I have created helper component to do that: import React, { FunctionComponent, Suspense } from 'react'; interface LazyMuiIconProps { name: string; } export const LazyMuiIcon: FunctionComponent<LazyMuiIconProps> = ({ name }) => { console.log(name); const IconElement = React.lazy(() => import(`@material-ui/icons/${name}`)); // const IconElement = React.lazy(() => import(`@material-ui/icons/Home`));

Exports defaults else path not taken with Jest and ES6

元气小坏坏 提交于 2021-02-07 19:22:22
问题 I'm having issues to pass my tests with 100% coverage. Istanbul say that exports defaults Component else path not taken. Because of that, I see in my generated html of istanbul that my tests are not completely at 100%. Mostly in the Statements and Branches tab. I'm using: React: 15.4.0 Jest: 17.0.2 Webpack: 1.12.11 Any idea? 回答1: The problem was in the jest configuration, we were using a preprocessor in order to resolve some imports: In the package json we had this: "transform": { "^.+\\.js$"

Webpack fails silently when named import doesn't exist

梦想的初衷 提交于 2021-02-07 18:32:57
问题 When I try to import a named import, it fails silently if the name import does not exist. Is there a way to get webpack to fail loudly when it cannot find the import at build time For example: // file1.js const var1 = 'var1' export { var1 } and // file2.js import { var2 } from './file1' // at this point, var2 is undefined at runtime because it was never exported from file1.js Instead, I want it to fail at build time. Is there a webpack option or some other technique I can use to catch this

Webpack fails silently when named import doesn't exist

杀马特。学长 韩版系。学妹 提交于 2021-02-07 18:32:34
问题 When I try to import a named import, it fails silently if the name import does not exist. Is there a way to get webpack to fail loudly when it cannot find the import at build time For example: // file1.js const var1 = 'var1' export { var1 } and // file2.js import { var2 } from './file1' // at this point, var2 is undefined at runtime because it was never exported from file1.js Instead, I want it to fail at build time. Is there a webpack option or some other technique I can use to catch this

Webpack fails silently when named import doesn't exist

时间秒杀一切 提交于 2021-02-07 18:32:34
问题 When I try to import a named import, it fails silently if the name import does not exist. Is there a way to get webpack to fail loudly when it cannot find the import at build time For example: // file1.js const var1 = 'var1' export { var1 } and // file2.js import { var2 } from './file1' // at this point, var2 is undefined at runtime because it was never exported from file1.js Instead, I want it to fail at build time. Is there a webpack option or some other technique I can use to catch this

你的Webpack优化了吗?

有些话、适合烂在心里 提交于 2021-02-07 17:51:15
(给 前端食堂 加星标,吃好每一顿) 引言 webpack 的打包优化一直是个老生常谈的话题,常规的无非就分块、拆包、压缩等。 本文以我自己的经验向大家分享如何通过一些分析工具、插件以及 webpack 新版本中的一些新特性来显著提升 webpack 的打包速度和改善包体积,学会分析打包的瓶颈以及问题所在。 本文演示代码,仓库地址:https://github.com/Jack-cool/webpack4(欢迎star啊 ) 速度分析 🏂 webpack 有时候打包很慢,而我们在项目中可能用了很多的 plugin 和 loader ,想知道到底是哪个环节慢,下面这个插件可以计算 plugin 和 loader 的耗时。 yarn add -D speed-measure-webpack-plugin 配置也很简单,把 webpack 配置对象包裹起来即可: const SpeedMeasurePlugin = require ( "speed-measure-webpack-plugin" ); const smp = new SpeedMeasurePlugin(); const webpackConfig = smp.wrap({ plugins : [ new MyPlugin(), new MyOtherPlugin() ] }); 来看下在项目中引入 speed

I want to use mediainfo.js in React.js without 'eject' command

*爱你&永不变心* 提交于 2021-02-07 16:45:14
问题 I'm trying to use mediainfo.js with React.js. Looking at the usage example in React.js of the above site, it is set by "webpack.config.js". However, when I build the environment using create-react-app , "webpack.config.js" is wrapped and it seems that it can not be edited without executing the 'eject' command. If you use npm package "react-app-rewired", you can edit it without executing the reject command, so I tried it. // config-override.js (overwrites webpack.config.js) const { resolve } =