require

vue-cli中webpack配置解析

不羁岁月 提交于 2020-02-27 08:36:19
版本号 vue-cli 2.8.1 (终端通过 vue -V 可查看) vue 2.2.2 webpack 2.2.1 目录结构 ├── README.md ├── build │ ├── build.js │ ├── check-versions.js │ ├── dev-client.js │ ├── dev-server.js │ ├── utils.js │ ├── vue-loader.conf.js │ ├── webpack.base.conf.js │ ├── webpack.dev.conf.js │ └── webpack.prod.conf.js ├── config │ ├── dev.env.js │ ├── index.js │ └── prod.env.js ├── index.html ├── package.json ├── src │ ├── App.vue │ ├── assets │ │ └── logo.png │ ├── components │ │ └── Hello.vue │ └── main.js └── static webpack配置 主要对build目录下的webpack配置做详细分析 webpack.base.conf.js 入口文件 entry entry: { app: '.src/main.js' } 输出文件

node.js-2

自作多情 提交于 2020-02-27 07:10:08
用Node.js创建一个静态服务器,然后将二阶段项目部署在这个服务器中 源代码: ```javascript var http = require( 'http' ); var port = 8080 ; var hostname = '127.0.0.1' var path = require( 'path' ) // 磁盘路径处理的模块 var fs = require( 'fs' ) // 操作文件、目录的模块 var url = require( 'url' ) // 处理url var server = http.createServer( function ( request, response ) { var staticPath = path.join( __dirname,'static' ) var urlObj = url.parse( request.url ) /* Url { protocol: null, slashes: null, auth: null, host: null, port: null, hostname: null, hash: null, search: null, query: null, pathname: '/static/css/index.css', path: '/static/css/index.css', href

webpack4 优化记录

旧街凉风 提交于 2020-02-27 05:18:54
webpack4.0优化那些事儿 一 缩小文件搜索范围 1 include & exclude 1) action 限制编译范围 2) useage module: { rules: [ { test: /\.js$/, use: ['babel-loader?cacheDirectory'], include: path.resolve(__dirname, 'src'), exclude: /node_modules/ } ] } 'babel-loader?cacheDirectory' You can also speed up babel-loader by as much as 2x by using the cacheDirectory option. This will cache transformations to the filesystem. QA 命令行warning [BABEL] Note: The code generator has deoptimised the styling of "/Users/xxx/Documents/xxx/webpack_test/test3/node_modules/lodash/lodash.js" as it exceeds the max of "500KB". 加上exclude限制范围就不会报错了 2

[PyJs系列介绍]一、从commonjs和seajs说起

瘦欲@ 提交于 2020-02-27 04:51:19
PyJs JavsScript Framework 项目地址: https://github.com/demix/PyJs 文档地址: http://demix.github.com/pyjs/ 这里的PyJs,不是已有的 Pyjamas , 暂不具体说PyJs是个神马东东,只说一句:PyJs是依赖于python的一个符合commonjs规范的浏览器端JavaScript Framework。所以,不喜欢写js有环境依赖的,可以点浏览器的x了,不好意思占用各位时间。 继续看的童鞋门,我们先来说一下commonjs。 Commonjs模块 wiki地址 http://wiki.commonjs.org/ module 1.1.1规范 http://wiki.commonjs.org/wiki/Modules/1.1.1 commonjs 的目标是定义一套普通应用程序使用的API,从而填补原生JavaScript标准库过少的缺点。终极目标是实现一个像python,java中含有的标准库。现在非常火爆的nodejs实际上就是commonjs的一个实现。 commonjs的module 1.1.1基本设计思路如下: Module上下文中,有一个require的函数。require接受一个module标志量,返回一个目标模块的api接口; Module上下文中,有一个exports变量

Ruby中的include和require有什么区别?

非 Y 不嫁゛ 提交于 2020-02-26 13:09:23
我的问题类似于“ 在Ruby中包含和扩展之间有什么区别? ”。 Ruby中的 require 和 include 什么区别? 如果我只想使用我班上某个模块中的方法,我是否 require 或 include 它? #1楼 如果使用模块,则意味着将所有方法都带入类中。 如果使用模块 extend 类,则意味着您将“引入”模块的方法作为 类 方法。 如果在模块中 include 类,则意味着您将“引入”模块的方法作为 实例 方法。 例如: module A def say puts "this is module A" end end class B include A end class C extend A end B.say => B:Class的未定义方法'say' B.new.say =>这是模块A C.say =>这是模块A C.new.say => C:Class的未定义方法'say' #2楼 您是否曾经尝试过 require 一个模块? 结果如何? 你试一试: MyModule = Module.new require MyModule # see what happens 不需要模块,仅包括模块! #3楼 从 Ruby 1.9编程开始 在继续之前,我们将对include语句提出几点要点。 首先,它与文件无关。 C程序员使用称为

gulp 搭建静态服务器

无人久伴 提交于 2020-02-26 12:49:37
步骤: 安装依赖:npm i browser-sync --save-dev 导入browser-sync,通过create创建 设置Sass和Js任务,将其压缩重命名并引入页面,任务结束时reload服务 设置默认任务,此任务负责,初始化服务器,监视setJs和setCss的变化 var gulp = require("gulp"); var browser = require("browser-sync").create(); var concat = require("gulp-concat"); var rename = require("gulp-rename"); var sass = require("gulp-sass"); var minifyCss = require("gulp-minify-css"); var uglify = require("gulp-uglify"); gulp.task("setJs",()=>{ gulp.src("./src/js/*.js") .pipe(concat("c.js")) .pipe(uglify()) .pipe(rename("c.min.js")) .pipe(gulp.dest("./dist")) .on("end",browser.reload); }); gulp.task("setSass",()

How to debug requireJS module defined path/file

拥有回忆 提交于 2020-02-26 06:40:49
问题 I'm new to RequireJS world. I'm getting Load Timeout error for one of the modules, which I've already defined in the main file. I don't see any request in Network tab of Chrome, probably because require has already loaded that file earlier. I've hooked to onError event of require & I see the error. But the stack doesn't give the exact location/name of the file which tried to load this module. Is there any way to figure out the exact file/linesOfCode ? Also, is there any way to figure out at

How to debug requireJS module defined path/file

China☆狼群 提交于 2020-02-26 06:40:26
问题 I'm new to RequireJS world. I'm getting Load Timeout error for one of the modules, which I've already defined in the main file. I don't see any request in Network tab of Chrome, probably because require has already loaded that file earlier. I've hooked to onError event of require & I see the error. But the stack doesn't give the exact location/name of the file which tried to load this module. Is there any way to figure out the exact file/linesOfCode ? Also, is there any way to figure out at

Koa1 框架

两盒软妹~` 提交于 2020-02-26 02:22:17
安装创建项目: 1.一定要全局安装(koa1.2和koa2都己经支持) npm install koa-generator -g 2. koa1 生成一个test项目,切到test目录并下载依赖 koa1创建项目 koa test cd test npm install 运行:npm start 访问:http://localhost:3000 Koa是一个类似于Express的Web开发框架,创始人也是同一个人。它的主要特点是,使用了ES6的Generator函数,进行了架构的重新设计。也就是说,Koa的原理和内部结构很像Express,但是语法和内部结构进行了升级。 官方 faq 有这样一个问题:”为什么koa不是Express 4.0?“,回答是这样的:”Koa与Express有很大差异,整个设计都是不同的,所以如果将Express 3.0按照这种写法升级到4.0,就意味着重写整个程序。所以,我们觉得创造一个新的库,是更合适的做法。“ Koa应用 一个Koa应用就是一个对象,包含了一个middleware数组,这个数组由一组Generator函数组成。这些函数负责对HTTP请求进行各种加工,比如生成缓存、指定代理、请求重定向等等。 1 var koa = require('koa'); 2 var app = koa(); 3 4 app.use(function *(){

webpack4+react 多页面打包

白昼怎懂夜的黑 提交于 2020-02-26 00:04:50
目录结构(先创建好) 简单说明一下 下面有代码的直接粘贴复制 有些没有代码的 这里先解释一下 1.node_modules 这个文件夹没什么好说的 2.src 这个文件夹里面就是我们需要写的 (1).src/component 这里一般都是方组件的 我没有写组件 所以这里空空如也 (2).src/pages 这里放的就是打包的页面了 (3).src/pages 里面pageinfo.json 这个文件是配置单独页面的一些seo之类的配置 不写的 生成模板是会有默认的 代码很简单 稍微看一下就明白 (4).关于.scss文件 因为我现在就在用scss 所有这里就用scss 没有用 css上面的 有需要的可以自己配置下百度一下很简单 下面就是一些主要代码 希望能对在看此篇文章的你起到帮助作用 一、生成模板文件 //create-html.js const fs = require("fs"); const HtmlWebpackPlugin = require("html-webpack-plugin"); //生成html文件 const getPath = require("./get-path"); let htmlArr = []; function createHtml(page_path) { getPath(page_path).map((item) => { let