Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #10

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open

Dev #10

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 18 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
*.DS_Store
.idea/
/node_modules/
/node_modules/
/.idea/
/docs/dsDocs/
/oldSource/
/src/dsx/
/WebH5Template/js/app/
/WebH5Template/js/app/test/
/WebH5Template/js/app/pages/
/WebH5Template/assets/test/
/WebH5Template/assets/media/
/WebH5Template/src/libs/
/WebH5Template/src/libs/
/WebH5Template/src/app/pages/
/WebH5Template/src/dsx/
/WebH5Template/src/ds/
/WebH5Template/src/threejs/
package-lock.json
*.DS_Store
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
# DsLibs
### Ds 互动代码库

[DsLibs Doc]( https://lqloveball.github.io/DsLibsDocs/)
> Ds是累积平时项目工作的经验代码库,不属于工作职位任务与项目的内容。代码库大部分理念来至曾经as开发时候积累。
为快速开发H5互动项目而生

---

> Ds库里代码参考网络与其他开源代码库,在自己理解上进行整合。所以Ds库也是开源开放,可以使用在所属的职位任务与项目中,希望这样能有更多交流与指出Ds代码不足.
npm run 命令说明:

---
- docs_dev 编写文档开发环境
- doc_server 运行本地文档浏览
- docs jsdocs 进行api文档打包
- delComments 测试删注释代码转换

> Ds库是代码工具类的集合,每个工具类尽量做属于自己负责的工作内容,实际执行项目希望如搭积木一样去使用这些类。尽力减小类之间依赖关系。
### WebH5Temaplate模板

---
npm run 命令说明:

> Ds库结合Ds的项目开发模板,越过每次繁琐的项目结构代建。直接进入到项目逻辑程序的编写开发
- dev 项目代码不压缩 开发时候使用
- bin 项目代码压缩 项目部署使用
- gulpDev 等同 dev 因为window下npm 并行执行命令支持不好
- gulpBin 等同 bin 因为window下npm 并行执行命令支持不好

---
其他 npm run 命令说明:

- server 只启动http服务
- webpack-dev webpack开发编译模式不带 http服务
- webpack-bin webpack部署编译模式不带 http服务
- debug 模板测试
4 changes: 4 additions & 0 deletions WebH5Template/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": [["es2015", { "modules": false }]],
"plugins": ["transform-object-rest-spread"]
}
7 changes: 7 additions & 0 deletions WebH5Template/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#井号是注释 根据自己的项目需要进行忽略
# 如果 .eslintrc 开启了 env nodejs 那么 默认 node_modules是自动忽略的
node_modules
/node_modules/**
*.sh
js
build/**
15 changes: 15 additions & 0 deletions WebH5Template/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "eslint:recommended",
"env":{
"node":true,
"es6":true
},
"rules": {
"semi": ["error", "always"],
"quotes": "off",
"no-console":"off",
"no-unused-vars":"off",
"no-unreachable":"off",
"no-redeclare":"warn"
}
}
File renamed without changes.
File renamed without changes.
150 changes: 150 additions & 0 deletions WebH5Template/build/gulpDebugTemp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
var gulp = require('gulp'); //gulp
var fs = require('fs'); //文件系统
var glob = require('glob');
var path = require('path'); //路径习题
var del = require('del'); //文件删除
var newer = require('gulp-newer'); //快速创建copy
var copy = require('gulp-copy'); //拷贝
var watch = require('gulp-watch'); //观察者
var browserSync = require('browser-sync').create(); //自动刷新调试
var less = require('gulp-less'); //less编译
var lazyImageCSS = require('gulp-lazyimagecss'); // 自动为图片样式添加 宽/高/background-size 属性
var minifyCSS = require('gulp-minify-css'); //压缩css
// var concat = require('gulp-concat');//合并js文件成一个 有webpack后这个没有存在必要【不需要】
var usemin = require('gulp-usemin2'); //剥离html里面开发插入的js,替换成压缩的min
var uglify = require('gulp-uglify'); //js压缩
var rename = require('gulp-rename'); //重新命名
var removeCode = require('gulp-remove-code'); //进行删除指定块的代码
var replace = require('gulp-replace'); //进行字符替换
// var imagemin = require('gulp-imagemin');//jpg图片压缩 使用pp鸭 【不需要】
// var pngquant = require('imagemin-pngquant');//png图片压缩 【不需要】
// var webpack = require("webpack"); //webpack
// var _ = require('lodash'); //webpack配置更改

/**
* 刷新浏览器
* @param {[type]} value ['*.css']
* @return {[type]} [description]
*/
function browserReload(value) {
if (value) browserSync.reload(value);
else browserSync.reload();
}

/**
* 开发目录
* @type {Object}
*/
var developmentConfig = {
//监听 html 文件刷新
html: ['../*.html', '../html/**/*.html'],
//js html css 需要经过webpack编译
src: ['../src/**/*.js', '../src/**/*.html', '../src/**/*.css', '../src/**/*.vue'],
//编译出来文件目录
dist: '../js/app/',
//需要监听编译less文件
lesswatch: ['../less/*.less', '../less/**/*.less'],
//需要编译的less文件
lessbuild: ['../less/*.less'],
//less to css路径
cssPath: "../css/",
//css 变化监听
css: ['../css/*.css'],
//js 变化监听
js: ['../js/**/*.js'],
};
/**
* 清除webpack编译打包
* @type {[type]}
*/
gulp.task('clean:webpack', function () {
return del([
developmentConfig.dist,
], {
force: true
});
});
// 只要server
gulp.task('server', function () {
//启动browserSync服务
browserSync.init({
server: '../',
port: 8001,
open: "external"
});
//less编译监听
watch(developmentConfig.lesswatch, {
verbose: true
}, function (e) {
var cb = e.history[0];
gulp.src(developmentConfig.lessbuild)
.pipe(less().on('error', function (error) {
console.log(error.message);
}))
.pipe(lazyImageCSS()) //自动为图片样式添加 宽/高/background-size 属性
//.pipe(minifyCss({compatibility: 'ie8'}))
.pipe(gulp.dest(developmentConfig.cssPath));
});
//html变化监听
watch(developmentConfig.html, {
verbose: true
}, function (event) {
browserReload('*.html');
});
//js变化
watch(developmentConfig.js, {
verbose: true
}, function (event) {
browserReload();
});
//css 变化监听
watch(developmentConfig.css, {
verbose: true
}, function (e) {
browserReload('*.css');
});
});

gulp.task('dssource', function () {



gulp.src([
'../../src/ds/**/*.*',
]).pipe(
copy("../src/ds/", {prefix: 0})
);


gulp.watch(['../../src/ds/**/*.*'], function (event) {

var _path = event.path; //'..' + event.path.slice(event.path.indexOf("/src/ds/"));
var _fileName = event.path.slice(event.path.lastIndexOf("/src/ds/") + 8);
var _file = '../src/ds/' + _fileName;
var _outPath = _file.slice(0, _file.lastIndexOf("/"));

// console.log('File ' + event.path + ' was ' + event.type + ', running tasks>>', _path, ">>",
// _fileName,
// '_outPath:',_outPath
// );

if (event.type === 'deleted') {
del([_file], {force: true});
}
if (event.type === 'added' || event.type === 'changed') {

gulp.src([_path]).pipe(gulp.dest(_outPath));

}

});





});

gulp.task('default', ['dssource', 'clean:webpack', 'server']);

// gulp.task('default', ['dssource']);
File renamed without changes.
103 changes: 103 additions & 0 deletions WebH5Template/build/gulpWebpack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
var gulp = require('gulp'); //gulp
var fs = require('fs'); //文件系统
var glob = require('glob'); //全局
var path = require('path'); //路径习题
var del = require('del'); //文件删除
var newer = require('gulp-newer'); //快速创建copy
var copy = require('gulp-copy'); //拷贝
var watch = require('gulp-watch'); //观察者
var browserSync = require('browser-sync').create(); //自动刷新调试
var less = require('gulp-less'); //less编译
var lazyImageCSS = require('gulp-lazyimagecss'); // 自动为图片样式添加 宽/高/background-size 属性
var minifyCSS = require('gulp-minify-css'); //压缩css
var usemin = require('gulp-usemin2'); //剥离html里面开发插入的js,替换成压缩的min
var uglify = require('gulp-uglify'); //js压缩
var rename = require('gulp-rename'); //重新命名
var removeCode = require('gulp-remove-code'); //进行删除指定块的代码
var replace = require('gulp-replace'); //进行字符替换
// var concat = require('gulp-concat');//合并js文件成一个 有webpack后这个没有存在必要【不需要】
// var imagemin = require('gulp-imagemin');//jpg图片压缩 使用pp鸭 【不需要】
// var pngquant = require('imagemin-pngquant');//png图片压缩 【不需要】
var webpack = require("webpack"); //webpack
var _ = require('lodash'); //webpack配置更改

function browserReload(value) {
if (value)
browserSync.reload(value);
else
browserSync.reload();
}

var developmentConfig = {
//监听 html 文件刷新
html: [
'../*.html', '../html/**/*.html'
],
//js html css 需要经过webpack编译
src: [
'../src/**/*.js', '../src/**/*.html', '../src/**/*.css', '../src/**/*.vue'
],
//编译出来文件目录
dist: '../js/app/',
//需要监听编译less文件
lesswatch: [
'../less/*.less', '../less/**/*.less'
],
//需要编译的less文件
lessbuild: ['../less/*.less'],
//less to css路径
cssPath: "../css/",
//css 变化监听
css: ['../css/*.css'],
//js 变化监听
js: ['../js/**/*.js']
};
gulp.task('clean:webpack', function () {
return del([developmentConfig.dist], {force: true});
});
//http server 环境
gulp.task('webpack:dev', function () {
var _webpackConfig = require('./webpack.dev.config.js');
// console.log(JSON.stringify(_webpackConfig));
webpack(_webpackConfig).watch(200, function (err, stats) {
browserReload();
});
//启动browserSync服务
browserSync.init({
server: '../',
port: 8001,
open: "external"
});
//less编译监听
watch(developmentConfig.lesswatch, {
verbose: true
}, function (e) {
var cb = e.history[0];
gulp.src(developmentConfig.lessbuild)
.pipe(less().on('error', function (error) {
console.log(error.message);
}))
.pipe(lazyImageCSS()) //自动为图片样式添加 宽/高/background-size 属性
//.pipe(minifyCss({compatibility: 'ie8'}))
.pipe(gulp.dest(developmentConfig.cssPath));
});
//html变化监听
watch(developmentConfig.html, {
verbose: true
}, function (event) {
browserReload('*.html');
});
//js变化
watch(developmentConfig.js, {
verbose: true
}, function (event) {
browserReload();
});
//css 变化监听
watch(developmentConfig.css, {
verbose: true
}, function (e) {
browserReload('*.css');
});
});
gulp.task('default', ['clean:webpack', 'webpack:dev']);
Loading