From 65acff7dc0e530eb4acee1624ced5c19bf1b3eef Mon Sep 17 00:00:00 2001
From: "416921332@qq.com" <416921332@qq.com>
Date: Thu, 27 Apr 2017 11:08:14 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.editorconfig | 20 ++++++++++++++++++++
.gitignore | 3 ++-
recipes/webpack.babel/app.js | 10 +++++++---
recipes/webpack.babel/package.json | 4 ++--
recipes/webpack.babel/src/main.js | 1 -
recipes/webpack.babel/webpack.config.js | 18 +++++++++---------
6 files changed, 40 insertions(+), 16 deletions(-)
create mode 100644 .editorconfig
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..959db8a
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,20 @@
+# EditorConfig helps developers define and maintain consistent
+# coding styles between different editors and IDEs
+# http://editorconfig.org
+
+root = true
+
+[*]
+
+# Change these settings to your own preference
+indent_style = space
+indent_size = 2
+
+# We recommend you to keep these unchanged
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+# editorconfig-tools is unable to ignore longs strings or urls
+max_line_length = null
diff --git a/.gitignore b/.gitignore
index c69834c..22f04fa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,5 @@ npm-debug.log
.sass-cache
*.css.map
yarn.lock
-!/yarn.lock
\ No newline at end of file
+!/yarn.lock
+/recipes/webpack.babel/app/dist
diff --git a/recipes/webpack.babel/app.js b/recipes/webpack.babel/app.js
index 9bca28d..0df4b20 100644
--- a/recipes/webpack.babel/app.js
+++ b/recipes/webpack.babel/app.js
@@ -10,8 +10,13 @@ var stripAnsi = require('strip-ansi');
* Require ./webpack.config.js and make a bundler from it
*/
var webpackConfig = require('./webpack.config');
-var bundler = webpack(webpackConfig);
+//console.log(webpackConfig);
+var bundler = webpack(webpackConfig,(err, stats) => {
+ if (err || stats.hasErrors()) {
+ console.warn(err);
+ }
+});
/**
* Reload all devices when bundle is complete
* or send a fullscreen error message to the browser instead
@@ -26,13 +31,12 @@ bundler.plugin('done', function(stats) {
}
browserSync.reload();
});
-
/**
* Run Browsersync and use middleware for Hot Module Replacement
*/
browserSync.init({
server: 'app',
- open: false,
+ open: true,
logFileChanges: false,
middleware: [
webpackDevMiddleware(bundler, {
diff --git a/recipes/webpack.babel/package.json b/recipes/webpack.babel/package.json
index 15a6875..d601c05 100644
--- a/recipes/webpack.babel/package.json
+++ b/recipes/webpack.babel/package.json
@@ -18,7 +18,7 @@
"browser-sync": "^2.8.0",
"bs-fullscreen-message": "^1.0.0",
"strip-ansi": "^3.0.0",
- "webpack": "^1.10.5",
- "webpack-dev-middleware": "^1.2.0"
+ "webpack": "^2.4.1",
+ "webpack-dev-middleware": "^1.10.2"
}
}
diff --git a/recipes/webpack.babel/src/main.js b/recipes/webpack.babel/src/main.js
index 8a5c029..580e1eb 100644
--- a/recipes/webpack.babel/src/main.js
+++ b/recipes/webpack.babel/src/main.js
@@ -4,7 +4,6 @@ window.onload = function() {
let number = document.getElementById('number');
let incBtn = document.getElementById('inc');
let decBtn = document.getElementById('dec');
-
incBtn.addEventListener(
'click',
function() {
diff --git a/recipes/webpack.babel/webpack.config.js b/recipes/webpack.babel/webpack.config.js
index 71835bb..ef9979c 100644
--- a/recipes/webpack.babel/webpack.config.js
+++ b/recipes/webpack.babel/webpack.config.js
@@ -4,7 +4,6 @@ var webpack = require('webpack');
var path = require('path');
module.exports = {
- debug: true,
devtool: '#eval-source-map',
entry: ['./src/main'],
@@ -14,19 +13,19 @@ module.exports = {
publicPath: '/',
filename: 'dist/bundle.js'
},
-
- plugins: [new webpack.optimize.OccurenceOrderPlugin(), new webpack.NoErrorsPlugin()],
-
+ plugins: [
+ new webpack.LoaderOptionsPlugin({
+ debug: true
+ }),
+ new webpack.NoEmitOnErrorsPlugin()
+ ],
module: {
- loaders: [
+ rules: [
{
- loader: 'babel-loader',
-
// Only run `.js` and `.jsx` files through Babel
test: /\.jsx?$/,
-
+ loader: 'babel-loader',
exclude: /node_modules/,
-
// Options to configure babel with
query: {
plugins: ['transform-runtime'],
@@ -35,4 +34,5 @@ module.exports = {
}
]
}
+
};
From 07d67829b015ebb656c61e872b141b2d9ee4d438 Mon Sep 17 00:00:00 2001
From: "416921332@qq.com" <416921332@qq.com>
Date: Sat, 24 Jun 2017 13:01:51 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
recipes/webpack.babel/app.js | 1 +
recipes/webpack.babel/app/index.html | 17 ---
recipes/webpack.babel/includes/index.css | 25 ++++
recipes/webpack.babel/includes/index.js | 120 ++++++++++++++++++
recipes/webpack.babel/package.json | 31 ++++-
recipes/webpack.babel/src/actions.js | 7 -
recipes/webpack.babel/src/index.pug | 16 +++
recipes/webpack.babel/src/main.js | 54 ++++----
recipes/webpack.babel/src/test.js | 23 ++++
recipes/webpack.babel/views/access/login.pug | 4 +
.../views/includes/components.pug | 1 +
recipes/webpack.babel/webpack.config.js | 72 ++++++++++-
12 files changed, 321 insertions(+), 50 deletions(-)
delete mode 100644 recipes/webpack.babel/app/index.html
create mode 100644 recipes/webpack.babel/includes/index.css
create mode 100644 recipes/webpack.babel/includes/index.js
delete mode 100644 recipes/webpack.babel/src/actions.js
create mode 100644 recipes/webpack.babel/src/index.pug
create mode 100644 recipes/webpack.babel/src/test.js
create mode 100644 recipes/webpack.babel/views/access/login.pug
create mode 100644 recipes/webpack.babel/views/includes/components.pug
diff --git a/recipes/webpack.babel/app.js b/recipes/webpack.babel/app.js
index 0df4b20..c9e0adf 100644
--- a/recipes/webpack.babel/app.js
+++ b/recipes/webpack.babel/app.js
@@ -42,6 +42,7 @@ browserSync.init({
webpackDevMiddleware(bundler, {
publicPath: webpackConfig.output.publicPath,
stats: { colors: true }
+ ,quiet: true
})
],
plugins: ['bs-fullscreen-message'],
diff --git a/recipes/webpack.babel/app/index.html b/recipes/webpack.babel/app/index.html
deleted file mode 100644
index 646b8a9..0000000
--- a/recipes/webpack.babel/app/index.html
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
- Browsersync, Webpack + Babel
-
-
-
- Browsersync, Webpack + Babel Example
-
- 0
-
-
-
-
-
-
diff --git a/recipes/webpack.babel/includes/index.css b/recipes/webpack.babel/includes/index.css
new file mode 100644
index 0000000..54ba06d
--- /dev/null
+++ b/recipes/webpack.babel/includes/index.css
@@ -0,0 +1,25 @@
+body.loading *{
+ display:none;
+}
+body.loading .loadingTip{
+ border-radius:5px;
+ display:block;
+ background-color:#a4a4a4;
+ color:#fff;
+ font-size:20px;
+ width:100px;
+ height:100px;
+ line-height:100px;
+ text-align:center;
+ top: 50%;
+ left: 50%;
+ margin-left: -50px;
+ margin-top: -50px;
+ position: fixed;
+}
+body.loading .loadingTip p{
+ color:#fff;display:block;
+}
+body.loaded .loadingTip{
+ display:none;
+}
diff --git a/recipes/webpack.babel/includes/index.js b/recipes/webpack.babel/includes/index.js
new file mode 100644
index 0000000..78a5537
--- /dev/null
+++ b/recipes/webpack.babel/includes/index.js
@@ -0,0 +1,120 @@
+;(function(){
+window.VERSION = "#VERSION#";
+window.PROTOCOL = "http";
+if(window.location.href.indexOf("https:")>-1){
+ //window.location.href = window.location.href.replace(/https/, "http");
+ window.PROTOCOL = "https";
+ window.ISHTTPS = true;
+}else{
+ window.ISHTTPS = false;
+}
+function loadJs(src){
+ var body = document.getElementsByTagName('body')[0];
+ var script= document.createElement('script');
+ script.type= 'text/javascript';
+ script.src= src;
+ body.appendChild(script);
+}
+//loadJs(window.PROTOCOL+"://localhost:8000/CLodopfuncs.js");
+//测试环境
+if(window.location.href.indexOf("doc.mding.org")>-1){
+ window.HOSTNAME = window.PROTOCOL+'://dev.mding.org/gym';
+ window.PUSHNAME = window.PROTOCOL+'://dev.push.mding.org';
+}
+else if(window.location.href.indexOf("localhost")>-1||
+ window.location.href.indexOf("127.0.0.1")>-1 ||
+ window.location.href.indexOf("192.168.")>-1){
+ if(window.ISHTTPS == true){
+ window.HOSTNAME = '';
+ window.PUSHNAME = '';
+ //window.PUSHNAME = window.PROTOCOL+'://localhost:3000';//连接本地,local.app.js
+ }else{
+ window.HOSTNAME = window.PROTOCOL+'://dev.mding.org/gym';
+ window.PUSHNAME = window.PROTOCOL+'://dev.push.mding.org';
+ }
+}
+else{
+ window.HOSTNAME = window.PROTOCOL+'://tea.api.mding.org/gym';
+ window.PUSHNAME = window.PROTOCOL+'://tea.push.mding.org';
+}
+window.PRINT_PREVIEW = false;
+//window.HOSTNAME = window.PROTOCOL+'://10.1.23.162:8080/gym';
+
+//window.PUSHNAME = window.PROTOCOL+'://dev.push.mding.org:80';
+//window.PUSHNAME = window.PROTOCOL+'://127.0.0.1:3000';
+window.RESOURCE = {
+ "access.login":[
+ "scripts/controllers/access/login.min.js",
+ ],
+ "access.signUp":[
+ "scripts/controllers/access/signUp.min.js",
+ ],
+ "common.setting":["scripts/controllers/common/setting.min.js"],
+ "common.blocks":["scripts/controllers/common/blocks.min.js"],
+ "common.update":["scripts/controllers/common/update.min.js"],
+ "common.user":[
+ "scripts/controllers/common/user.min.js",
+ "views/common/user/modal.all.html"
+ ],
+ "fonter.modal":[
+ "views/fonter/modal.all.html",
+ "scripts/controllers/fonter/modals.min.js"
+ ],
+ "fonter.goods":[
+ "scripts/controllers/fonter/goods.min.js",
+ "views/fonter/goods/modal.all.html"
+ ],
+ "fonter.courses":["scripts/controllers/fonter/courses.min.js"],
+ "fonter.member":[
+ "scripts/controllers/fonter/member.min.js",
+ "views/fonter/member/modal.all.html"
+ ],
+ "fonter.sign":[
+ "scripts/controllers/fonter/sign.min.js",
+ "views/fonter/sign/modal.all.html"
+ ],
+ "fonter.accountGather":["scripts/controllers/fonter/accountGather.min.js"],
+ "fonter.bracelet":["scripts/controllers/fonter/bracelet.min.js"],
+ "fonter.deposit":["scripts/controllers/fonter/deposit.min.js"],
+ "fonter.reserve":["scripts/controllers/fonter/reserve.min.js"],
+ "finance.home":[
+ "scripts/controllers/finance/home.min.js",
+ "views/finance/home/modal.all.html"
+ ],
+ "finance.member":[
+ "scripts/controllers/finance/member.min.js",
+ "views/finance/member/modal.all.html"
+ ],
+ "finance.bill":[
+ "scripts/controllers/finance/bill.min.js",
+ "views/finance/bill/modal.all.html"
+ ],
+ "chainFinance.member":[
+ "scripts/controllers/chainFinance/member.min.js",
+ "views/chainFinance/member/modal.all.html"
+ ],
+ "chainFinance.bill":[
+ "scripts/controllers/chainFinance/bill.min.js",
+ "views/chainFinance/bill/modal.all.html"
+ ],
+ "chainFinance.home":["scripts/controllers/chainFinance/home.min.js"],
+ "fonter.accountLog":[
+ "scripts/controllers/fonter/accountLog.min.js",
+ "views/fonter/accountLog/modal.all.html"
+ ],
+ "admin.shopInfos":[
+ "scripts/controllers/admin/shopInfos.min.js",
+ "views/admin/shopInfos/modal.all.html"
+ ]
+}
+//获取设备列表
+window.MEDIA_DEVICE_INOFS = [];
+navigator.mediaDevices.enumerateDevices().then(function(d) {
+ var a = _.where(d,{kind:'videoinput'});
+ _.each(a,function(t,i){
+ var o = {text:t.label || '摄像头 ' + (i + 1),value:t.deviceId}
+ window.MEDIA_DEVICE_INOFS.push(o);
+ });
+}).catch(function(error){console.log('navigator.getUserMedia error: ', error);});
+
+})();
diff --git a/recipes/webpack.babel/package.json b/recipes/webpack.babel/package.json
index d601c05..6228917 100644
--- a/recipes/webpack.babel/package.json
+++ b/recipes/webpack.babel/package.json
@@ -6,18 +6,47 @@
"author": "Shane Osbourne",
"license": "MIT",
"scripts": {
- "start": "node app"
+ "dev": "node app",
+ "build": "webpack"
},
"dependencies": {},
"devDependencies": {
+ "angular": "^1.6.4",
+ "angular-animate": "^1.6.4",
+ "angular-base64": "^2.0.5",
+ "angular-bootstrap": "^0.12.2",
+ "angular-mask": "^1.4.0",
+ "angular-md5": "^0.1.10",
+ "angular-sanitize": "^1.6.4",
+ "angular-ui-router": "^1.0.3",
+ "angular-ui-utils": "^0.1.1",
+ "angularjs-toaster": "^2.1.0",
"babel-core": "^6.1.2",
"babel-loader": "^6.1.0",
"babel-plugin-transform-runtime": "^6.1.2",
"babel-preset-es2015": "^6.1.2",
"babel-preset-stage-0": "^6.1.2",
+ "bootstrap": "^3.3.7",
"browser-sync": "^2.8.0",
"bs-fullscreen-message": "^1.0.0",
+ "css-loader": "^0.28.4",
+ "favicons-webpack-plugin": "^0.0.7",
+ "file-loader": "^0.11.2",
+ "html-webpack-plugin": "^2.28.0",
+ "jquery": "^2.2.4",
+ "moment": "^2.18.1",
+ "ngstorage": "^0.3.11",
+ "node-sass": "^4.5.3",
+ "oclazyload": "^1.1.0",
+ "pug": "^2.0.0-rc.2",
+ "pug-loader": "^2.3.0",
+ "raw-loader": "^0.5.1",
+ "sass-loader": "^6.0.6",
+ "socket.io-client": "^2.0.3",
"strip-ansi": "^3.0.0",
+ "style-loader": "^0.18.2",
+ "underscore": "^1.8.3",
+ "url-loader": "^0.5.9",
"webpack": "^2.4.1",
"webpack-dev-middleware": "^1.10.2"
}
diff --git a/recipes/webpack.babel/src/actions.js b/recipes/webpack.babel/src/actions.js
deleted file mode 100644
index 22a7d60..0000000
--- a/recipes/webpack.babel/src/actions.js
+++ /dev/null
@@ -1,7 +0,0 @@
-export function inc(value) {
- return value + 10;
-}
-
-export function dec(value) {
- return value - 10;
-}
diff --git a/recipes/webpack.babel/src/index.pug b/recipes/webpack.babel/src/index.pug
new file mode 100644
index 0000000..22d5c9e
--- /dev/null
+++ b/recipes/webpack.babel/src/index.pug
@@ -0,0 +1,16 @@
+doctype html
+html(lang="en-US")
+ head
+ title 美加美·健身·PC
+ meta(charset="utf-8")
+ meta(http-equiv="Expires" content="0")
+ meta(http-equiv="Pragma" content="no-cache")
+ meta(http-equiv="Cache-control" content="no-cache")
+ meta(http-equiv="Cache" content="no-cache")
+ meta(name="apple-mobile-web-app-capable" content="yes")
+ meta(name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1")
+ body
+ h1 Browsersync, Webpack + Babel Example1112
+ span#number 1
+ button#inc(type="button") Increase
+ button#dec(type="button") Decrease
diff --git a/recipes/webpack.babel/src/main.js b/recipes/webpack.babel/src/main.js
index 580e1eb..3dd6dc1 100644
--- a/recipes/webpack.babel/src/main.js
+++ b/recipes/webpack.babel/src/main.js
@@ -1,22 +1,32 @@
-import { inc, dec } from './actions';
-
-window.onload = function() {
- let number = document.getElementById('number');
- let incBtn = document.getElementById('inc');
- let decBtn = document.getElementById('dec');
- incBtn.addEventListener(
- 'click',
- function() {
- number.innerHTML = inc(+number.innerHTML);
- },
- false
- );
-
- decBtn.addEventListener(
- 'click',
- function() {
- number.innerHTML = dec(+number.innerHTML);
- },
- false
- );
-};
+import '../sass/bootstrap.scss';
+import '../sass/bootstrap-theme.scss';
+import '../bower_components/animate.css/animate.css';
+import '../bower_components/angularjs-toaster/toaster.min.css';
+import '../includes/index.css';
+import '../bower_components/webrtc-adapter/release/adapter_no_edge.js';
+import _ from 'underscore';
+import 'bootstrap';
+import angular from 'angular';
+import 'angular-animate';
+import 'angular-bootstrap';
+import 'angular-md5';
+import 'angular-sanitize';
+import 'angular-ui-router';
+import 'ngstorage';
+import 'angularjs-toaster';
+import 'oclazyload';
+import 'angular-base64';
+import 'moment';
+import '../bower_components/angular-mask/dist/ngMask.js';
+import '../bower_components/angular-ui-utils/ui-utils.js'
+import '../bower_components/printThis/printThis.js';
+import '../bower_components/laydate/laydate.js';
+import '../bower_components/laydate/need/laydate.css';
+import '../bower_components/laydate/skins/default/laydate.css';
+import '../bower_components/ngmodel-format/src/ngmodel.format.js';
+import '../bower_components/moment/moment-locales.js';
+import '../bower_components/moment/moment-precise-range.js';
+//let template = require('../views/access/login.pug');
+//let locals = { /* ... */ };
+//let html = template(locals);
+//console.log(template(locals));
diff --git a/recipes/webpack.babel/src/test.js b/recipes/webpack.babel/src/test.js
new file mode 100644
index 0000000..5d8b22b
--- /dev/null
+++ b/recipes/webpack.babel/src/test.js
@@ -0,0 +1,23 @@
+(function() {
+ console.log("this is test.js in src ");
+ let root = this;
+ //let previousUnderscore = root._;
+ console.log("this",this);
+ let _ = function(){
+
+ }
+ if (typeof exports !== 'undefined') {
+ if(typeof module !== 'undefined' && module.exports){
+ exports = module.exports = _;
+ }
+ exports._ = _;
+ } else {
+ root._ = _;
+ }
+ _.VERSION = '1.8.3';
+ if (typeof define === 'function' && define.amd) {
+ define('underscore', [], function() {
+ return _;
+ });
+ }
+}.call(this));
diff --git a/recipes/webpack.babel/views/access/login.pug b/recipes/webpack.babel/views/access/login.pug
new file mode 100644
index 0000000..183f64e
--- /dev/null
+++ b/recipes/webpack.babel/views/access/login.pug
@@ -0,0 +1,4 @@
+#page_login
+ .m-l-xxl.xs-m-l-md
+ p 123
+ include ../includes/components.pug
diff --git a/recipes/webpack.babel/views/includes/components.pug b/recipes/webpack.babel/views/includes/components.pug
new file mode 100644
index 0000000..507023e
--- /dev/null
+++ b/recipes/webpack.babel/views/includes/components.pug
@@ -0,0 +1 @@
+p 4567
diff --git a/recipes/webpack.babel/webpack.config.js b/recipes/webpack.babel/webpack.config.js
index ef9979c..d3b9be9 100644
--- a/recipes/webpack.babel/webpack.config.js
+++ b/recipes/webpack.babel/webpack.config.js
@@ -1,6 +1,8 @@
// For instructions about this file refer to
// webpack and webpack-hot-middleware documentation
var webpack = require('webpack');
+var HtmlWebpackPlugin = require('html-webpack-plugin');
+var FaviconsWebpackPlugin = require('favicons-webpack-plugin')
var path = require('path');
module.exports = {
@@ -14,10 +16,31 @@ module.exports = {
filename: 'dist/bundle.js'
},
plugins: [
- new webpack.LoaderOptionsPlugin({
- debug: true
+ new webpack.ProvidePlugin({
+ $: 'jquery'
+ ,jQuery: 'jquery'
+ ,'window.jQuery':'jquery'
}),
- new webpack.NoEmitOnErrorsPlugin()
+ new webpack.LoaderOptionsPlugin({
+ debug: false
+ })
+ ,new webpack.NoEmitOnErrorsPlugin()
+ ,new HtmlWebpackPlugin({
+ hash:true
+ ,template: 'src/index.pug'
+ ,favicon:"images/favicon.ico"
+ })
+ // ,new FaviconsWebpackPlugin({
+ // logo: './images/screen_icon-144.png',
+ // prefix: 'icons-[hash]/',
+ // title: '美加美·健身·PC',
+ // icons: {
+ // android: true,
+ // appleIcon: true,
+ // appleStartup: true,
+ // favicons: false
+ // }
+ // })
],
module: {
rules: [
@@ -32,6 +55,49 @@ module.exports = {
presets: ['es2015', 'stage-0']
}
}
+ ,{
+ test: /\.pug?$/,
+ use: [
+ {
+ loader: 'pug-loader',
+ query: {pretty: true}
+ }
+ ]
+ }
+ ,{
+ test: /\.scss$/,
+ use: [{
+ loader: "style-loader"
+ }, {
+ loader: "css-loader"
+ }, {
+ loader: "sass-loader"
+ }]
+ }
+ ,{
+ test: /\.css$/,
+ use: [{
+ loader: "style-loader"
+ }, {
+ loader: "css-loader"
+ }]
+ }
+ ,{
+ test: /\.(eot|woff|woff2|svg|ttf)([\?]?.*)$/,
+ loader: "file-loader"
+ }
+ ,{
+ test: /\.(png|jpg|gif)$/,
+ use: [
+ {
+ loader: 'url-loader',
+ options: {
+ limit: 8192
+ ,prefix:"name=images/[hash:8].[name].[ext]"
+ }
+ }
+ ]
+ }
]
}