Webpack

vue项目(webpack+mintui),使用hbuilder打包app

眉间皱痕 提交于 2021-01-26 09:09:54
一、配置config/index.js 本人没有配置index.js文件,就开始进行了打包,结果最终效果是页面空白,解决了空白,接着底部图标(我是用的阿里巴巴图片)资源找不到。所以配置这步比较重要。 (1)页面空白的解决: 打开config/index.js,将build模块的assetsPublicPath值改为’./’ assetsPublicPath: './', 发布路径 (2)css引用图片资源找不到问题: 因为打包后路径发生变化,导致这个图片就找不到。 stackflow上有一个解决办法,很简单打开“build/utils.js”,增加一行代码即可 publicPath:'../../'    二、通过webpack打包 执行这样命令后,可以看到根目录的dist文件夹下是打包好的静态资源 这样就打包好了,里面有index.html 以及 static文件夹(包含fonts、img、js、css文件夹)两个 三、使用hbuilder打开 将dist文件下拖动到huilder软件中即可 dist文件夹,就是拖动进去的,A 标记是app的意思,W是web的意思。我这里是已经转为app了,所以dist文件夹以 A 标识 ,没有转换之前是 W 标识 四、转换为移动APP 由于我已经转为APP,我用helloHBuilder做示范 右键需要转为app的文件夹,弹出的快捷菜单中——

Chrome浏览器上安装Vue Devtools

痞子三分冷 提交于 2021-01-25 05:55:03
<div id="cnblogs_post_body" class="blogpost-body"><p>Vue.js devtools是基于google chrome浏览器的一款调试vue.js应用的开发者浏览器扩展,可以在浏览器开发者工具下调试代码。</p> <p>1)首先在github下载devtools源码,地址:<a style="color: #3194d0; text-decoration: none; background-color: transparent;" href="https://github.com/vuejs/vue-devtools%E3%80%82" target="_blank">https://github.com/vuejs/vue-devtools。</a></p> <p><img src="https://images2017.cnblogs.com/blog/1215920/201709/1215920-20170919205434540-2015837660.png" alt=""></p> <p> </p> <p><br> 2)下载好后进入vue-devtools-master工程 执行cnpm install, 下载依赖,然后执行npm run build,编译源程序。</p> <p><img src="https:/

若重要,总会想办法(Vue学习笔记two)

微笑、不失礼 提交于 2021-01-24 14:30:25
志向太远,不可怕;没有到达,不可怕;可怕的是没有志向,失去了奋斗的方向。 你好,我是梦阳辰!期待与你相遇! 01.插槽slot 为什么要使用插槽? slot翻译为插槽: 在生活中很多地方都有插槽,电脑的USB插槽,插板当中的电源插槽。 插槽的目的是让我们原来的设备具备更多的扩展性。 比如电脑的USB我们可以插入U盘、硬盘、手机、音响、键盘、鼠标等等 组件的插槽 组件的插槽也是为了让我们封装的组件 更加具有扩展性 。让 使用者 可以决定组件内部的一些 内容 到底展示什么。 例子∶移动网站中的导航栏。 移动开发中,几乎每个页面都有导航栏。 导航栏我们必然会封装成一个插件,比如 nav-bar 组件。一旦有了这个组件,我们就可以在多个页面中复用了。但是,每个页面的导航是一样的吗? 不一样! 即不同的组件要求展示的东西不一样,插槽就可以解决这个问题。 <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <script src="../res/js/vue.js"></script></head><body><cpn></cpn><div id="app"> <my-cpn><button>我是被插入的东西1</button></my-cpn> <my-cpn><button

聊聊前端日常面试中的套路

二次信任 提交于 2021-01-24 11:46:18
关注 “重度前端” 助力前端深度学习 ━━━━━ 前言 2018年的秋天,金九银十的秋招季🍁,很荣幸,我也加入了跳槽求职的大部队🙃,虽然招聘热潮没有每年年初那样疯狂,但是还是看得出很多公司都在大量的求贤,和以往的跳槽不同,这次我主要通过猎头去寻找面试机会,因为在上一份工作中从猎头那里尝到了一点甜头,那就是会帮你要薪资嘛😏。 但是也有不好的地方,我把我的简历在猎聘等招聘平台上公开后,每天都有不计其数的猎头打电话过来推荐职位,而且每个猎头都要加到你的微信,可能会出现的问题是,他们给你推荐的职位不一定是你喜欢的公司,也不一定是适合你的,有的公司当你去面试了才发现你并不喜欢,这就浪费了双方的时间成本。 所以最近面了很多家,大厂、中厂、小厂、创业的都面过,见识到了各种面试官,也被问到各种面试题,也收到几个offer,但自己满意的确甚少,回想最近的经历,想做一个总结,总结一下面试中可以用的一些套路,和可能会遇到的一些套路。 正文 我把整个面试分为面试前、面试中、和面试后三个阶段,每个阶段都有每个阶段的套路。 我想到的和遇到的套路有限,后续会补充更新,所以这条“路”暂时还没有很长。。。 话不多数,上车🚌。。。 面试前 1. 简历的准备 好的简历是获取更多面试机会的前提,关于如何写一份优质的简历和简历优化等方面的话题我也不是专家,在这里说一下自己的总结。 简历中的重要部分 你目前掌握的技能

How to trigger hot reloading for React when a package in node_modules is changed?

人走茶凉 提交于 2021-01-24 11:42:09
问题 I am building a React component library and additional documentation project. My goal is to display immediately all changes of the library straight into the documentation. So far I have configured webpack to watch for changes in the components. After rebuilding, I take the output folder and move it in the node_modules of the documentation. This way I can simulate using my component library as an external package. The documentation is a create-react-app project and by default it does not watch

Import Javascript files as a string?

我的未来我决定 提交于 2021-01-24 10:52:27
问题 I want to be able to simply do an import file from 'file.js and then have file be a string of the contents within file.js. I've toyed around with raw-loader but it doesn't give me the same contents (instead it loads it in a different format). Any suggestions? 回答1: it doesn't give me the same contents (instead it loads it in a different format) That seems to mean that there are other loaders from your config applied to the file. You can enforce that only the loader in the import statement is

How can I automatically load all JSON files from a given directory in Webpack? [duplicate]

懵懂的女人 提交于 2021-01-23 10:59:11
问题 This question already has answers here : How to load all files in a directory using webpack without require statements (6 answers) Closed 4 years ago . Edit: There is an existing question about loading multiple files but does not adequately address how to combine JSON files into a single object. See answer below. This question is not a duplicate. I have a directory with 100 or so JSON files that I want to load into my js app, which is bundled via WebPack. I could go through the initial pain

Setting up ENV Variables Without create-react-app

别等时光非礼了梦想. 提交于 2021-01-23 06:36:27
问题 What would be the process of setting up ENV variables to work in your react project when your react project isn't built using create-react-app, and has no backend? 回答1: Found the answer. Quoted from this post by Aminu Kano. Webpack Users If you are using webpack, you can install and use dotenv-webpack plugin, to do that follow steps below: Install the package yarn add dotenv-webpack OR npm i dotenv-webpack // .env API_KEY='my secret api key' Add it to webpack.config.js file // webpack.config

Resolve Absolute / Alias Imports in Components with Storybook

风流意气都作罢 提交于 2021-01-23 06:03:12
问题 I'm using gatsby-plugin-alias-imports to be able to do absolute imports like so: import { colors } from "@styles/theme"; This is set up in the gatsby-config . Now I've just added storybook to my project. Since storybook doesn't run through gatsby, the alias imports won't resolve and I get an error: ERROR in ./src/components/Button/index.js Module not found: Error: Can't resolve '@styles/theme' in ... This makes sense. Storybook doesn't know what to do with @styles... - but how can I fix this?

若重要,总会想办法(Vue学习笔记two)

丶灬走出姿态 提交于 2021-01-23 00:26:31
志向太远,不可怕;没有到达,不可怕;可怕的是没有志向,失去了奋斗的方向。 你好,我是梦阳辰!期待与你相遇! 01.插槽slot 为什么要使用插槽? slot翻译为插槽: 在生活中很多地方都有插槽,电脑的USB插槽,插板当中的电源插槽。 插槽的目的是让我们原来的设备具备更多的扩展性。 比如电脑的USB我们可以插入U盘、硬盘、手机、音响、键盘、鼠标等等 组件的插槽 组件的插槽也是为了让我们封装的组件 更加具有扩展性 。让 使用者 可以决定组件内部的一些 内容 到底展示什么。 例子∶移动网站中的导航栏。 移动开发中,几乎每个页面都有导航栏。 导航栏我们必然会封装成一个插件,比如 nav-bar 组件。一旦有了这个组件,我们就可以在多个页面中复用了。但是,每个页面的导航是一样的吗? 不一样! 即不同的组件要求展示的东西不一样,插槽就可以解决这个问题。 < ! DOCTYPE html > < html lang = "en" > < head > < meta charset = "UTF-8" > < title > Title < / title > < script src = "../res/js/vue.js" > < / script > < / head > < body > < cpn > < / cpn > < div id = "app" > < my - cpn >