Webpack

How can I configure Storybook.js Webpack to work with absolute image paths in CSS modules in a Next.js project?

瘦欲@ 提交于 2020-12-12 11:25:05
问题 I am trying to configure Storybook to work with Next.js, Ant Design, Less, and TypeScript. In Next.js, images have to be stored in the public/ folder and referenced with absolute paths to be used throughout the project. I am having trouble configuring the Storybook.js webpack to be able to resolve these absolute image paths. For example, in a CSS module I could have: .testImage { background-image: url('/images/cucumber.png'); background-repeat: no-repeat; background-size: contain; height:

Methods like modal() not working if Bootstrap loaded with Webpack (Rails)

安稳与你 提交于 2020-12-12 03:19:10
问题 In my Rails 5 app, if I load Bootstrap 4 using a header <script> tag from a CDN, everything works fine. But when I install Bootstrap (and its dependencies) to node_modules , and serve it with Webpack, it mostly still works... but the jQuery methods Bootstrap is supposed to add like $(foo).modal() or $(bar).popover() give errors in the JavaScript console: Uncaught TypeError: $(...).modal is not a function Uncaught TypeError: $(...).popover is not a function There are several other

使用vue-cli搭建vue项目

白昼怎懂夜的黑 提交于 2020-12-12 01:29:59
1.安装node环境,然后在命令行输入node -v 和npm -v 查看版本号 2.在正式开始项目之前我们先介绍一下vue-cli,vue-cli是一个脚手架工具,vue-cli是帮助我们写好vue.js基础代码的工具,可以帮助我们生成一个项目目录,可以本地调试,单元测试,代码部署等等。 安装vue-cli $ npm install -g vue-cli 开始创建项目 使用vue-cli $ vue init <template-name> <project-name> 第一个是模板名称,第二个是项目名称,模板有webpack,webpack-simple ,browserify ,browserify-simple ,simple我们这个项目使用的是 webpack 。 下面我们就来搭建一个项目名称为myvue模板为webpack的vue项目(注:此处项目名不可有大写): vue init webpack myvue 接下拉终端里面会问你(也可能会跟你说vue不是内部或外部命令,本篇文章结尾会有解决办法) ? Project name (myvue) 项目名称是不是 myvue ,我们按回车,表示,是。当然,你也可以重写一个,然后回车。 然后 ? Project description (A Vue.js project) 项目描述,一个 vue.js 的项目。同样

devServer proxy in config throws 404

*爱你&永不变心* 提交于 2020-12-10 08:21:15
问题 I have this in src/vue.config.js module.exports = { devServer: { proxy: { '/api': { target: 'http://localhost:8081', changeOrigin: true, }, }, }, }; and I'm calling the api with axios.get('/api/parts') .then(result => commit('updateParts', result.data)) .catch(console.error); But I just keep getting Error: "Request failed with status code 404" And I can see the request is being made to port 8080 instead of 8081 I can access the api in the browser with no problems How can I debug this? 回答1:

深入解析ES6中let和闭包

故事扮演 提交于 2020-12-10 06:39:23
本篇文章主要介绍了深入理解ES6中let和闭包,写的十分的全面细致,具有一定的参考价值,对此有需要的朋友可以参考学习下。如有不足之处,欢迎批评指正。 本文介绍了深入理解ES6中let和闭包,分享给大家,具体如下: 在开始本文之前我们先来看一段代码 for(var i=0;i<10;i++){ arr[i]=function(){ return i; } } console.log(arr[3]());//10 //欢迎加入前端全栈开发交流圈一起吹水聊天学习交流:864305860 显然这段代码输出10,并没有向我们期望的返回3,原因也很简单(js的变量提升)函数在调用时候访问的是一个全局作用域的i,此时for循环已经执行完毕,全局变量i=10; 在ES5标准中,我们要想返回期望的3,通常的做法也很简单,就是让数组中的每个函数有单独的作用域,那么我们只要构造一个立即执行函数即可(js中没有块级作用域,只区分函数作用域和全局作用域)就像下面这样: var array=[]; for(var i=0;i<10;i++){ array[i]=(function(i){ return function(){ return i; } })(i); } console.log(array[3]());//3 //欢迎加入前端全栈开发交流圈一起吹水聊天学习交流:864305860

vue-router history模式下,子路由以及刷新页面not found问题解决

╄→尐↘猪︶ㄣ 提交于 2020-12-10 05:47:48
之前一直用的都是hash模式,最近的项目是导师写好的前端,我来搞后端,因为她弄的是history模式,本地调试没问题,打包后启动服务器就会遇到子页面刷新后not found,以及多级路由也not found的情况。 因为vue的路由是在浏览器中进行管理,如果刷新 http://localhost:3011/ 时可以访问到的,因为请求/路径,node将其指向了index.html(因为webpack打包会把index.html打包到根目录,而koa-webpack在没有传递参数的情况下也是指向的webpack配置文件中output中的publicPath,配置文件中配置的是/,所以默认/请求指向index.html),以下是koa-webpack中默认配置的源代码 ![Paste_Image.png](http: // upload-images.jianshu.io/upload_images/1210894-bb4f6395ba003114.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240z 而/example1请求到node,node会去寻找node端的路由处理,因为node端没有配置这个路由,所有找不到。 如果想要访问到/example1,需要请求到index.html,然后由vue的路由处理找到对应的模块 查了一圈

Webpack 5: devtool ValidationError, invalid configuration object

别说谁变了你拦得住时间么 提交于 2020-12-09 07:16:20
问题 While migrating from Webpack 4 to Webpack 5 I got an error when using devtool with empty value (only in production mode). module.exports = { devtool: isProd ? '' : 'source-map', // entry: ... // output: ... // module: ... } The message in the console: ValidationError: Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema. - configuration.devtool should match pattern "^(inline-|hidden-|eval-)?(nosources-)?(cheap-(module-)?)

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

可紊 提交于 2020-12-09 05:28:25
问题 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:19:23
问题 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:17: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.