Showing
3 changed files
with
112 additions
and
42 deletions
1 | -{ | ||
2 | - "name": "yohobuy-node", | ||
3 | - "version": "0.0.1", | ||
4 | - "description": "A New Yohobuy Project With Express", | ||
5 | - "repository": { | ||
6 | - "type": "git", | ||
7 | - "url": "http://git.dev.yoho.cn/web/yohobuy-node.git" | ||
8 | - }, | ||
9 | - "license": "MIT", | ||
10 | - "dependencies": { | ||
11 | - "express": "^4.13.1", | ||
12 | - "body-parser": "^1.15.0", | ||
13 | - "cookie-parser": "^1.4.1", | ||
14 | - "express-handlebars": "^3.0.0", | ||
15 | - "lodash": "^4.8.2", | ||
16 | - "morgan": "^1.7.0", | ||
17 | - "request-promise": "^2.0.1", | ||
18 | - "serve-favicon": "^2.3.0" | ||
19 | - }, | ||
20 | - "devDependencies": { | ||
21 | - "gulp": "^3.9.1", | ||
22 | - "autoprefixer": "^6.3.6", | ||
23 | - "gulp-cssnano": "^2.1.2", | ||
24 | - "gulp-postcss": "^6.1.0", | ||
25 | - "gulp-sourcemaps": "^2.0.0-alpha", | ||
26 | - "postcss-assets": "^4.0.1", | ||
27 | - "postcss-cachebuster": "^0.1.2", | ||
28 | - "postcss-calc": "^5.2.1", | ||
29 | - "postcss-center": "^1.0.0", | ||
30 | - "postcss-clearfix": "^1.0.0", | ||
31 | - "postcss-crip": "^2.0.0", | ||
32 | - "postcss-opacity": "^3.0.0", | ||
33 | - "postcss-position": "^0.4.0", | ||
34 | - "postcss-short": "^1.4.0", | ||
35 | - "postcss-sprites": "^3.1.2", | ||
36 | - "postcss-use": "^2.0.2", | ||
37 | - "precss": "^1.4.0", | ||
38 | - "webpack": "^1.13.0", | ||
39 | - "webpack-dev-server": "^1.14.1", | ||
40 | - "webpack-stream": "^3.1.0" | ||
41 | - } | ||
42 | -} | ||
1 | +{ | ||
2 | + "name": "yohobuy-node", | ||
3 | + "version": "0.0.1", | ||
4 | + "description": "A New Yohobuy Project With Express", | ||
5 | + "repository": { | ||
6 | + "type": "git", | ||
7 | + "url": "http://git.dev.yoho.cn/web/yohobuy-node.git" | ||
8 | + }, | ||
9 | + "license": "MIT", | ||
10 | + "dependencies": { | ||
11 | + "body-parser": "^1.15.0", | ||
12 | + "cookie-parser": "^1.4.1", | ||
13 | + "express": "^4.13.1", | ||
14 | + "express-handlebars": "^3.0.0", | ||
15 | + "lodash": "^4.8.2", | ||
16 | + "morgan": "^1.7.0", | ||
17 | + "request-promise": "^2.0.1", | ||
18 | + "serve-favicon": "^2.3.0", | ||
19 | + "shelljs": "^0.7.0" | ||
20 | + }, | ||
21 | + "devDependencies": { | ||
22 | + "autoprefixer": "^6.3.6", | ||
23 | + "gulp": "^3.9.1", | ||
24 | + "gulp-cssnano": "^2.1.2", | ||
25 | + "gulp-postcss": "^6.1.0", | ||
26 | + "gulp-sourcemaps": "^2.0.0-alpha", | ||
27 | + "gulp-util": "^3.0.7", | ||
28 | + "postcss-assets": "^4.0.1", | ||
29 | + "postcss-cachebuster": "^0.1.2", | ||
30 | + "postcss-calc": "^5.2.1", | ||
31 | + "postcss-center": "^1.0.0", | ||
32 | + "postcss-clearfix": "^1.0.0", | ||
33 | + "postcss-crip": "^2.0.0", | ||
34 | + "postcss-opacity": "^3.0.0", | ||
35 | + "postcss-position": "^0.4.0", | ||
36 | + "postcss-short": "^1.4.0", | ||
37 | + "postcss-sprites": "^3.1.2", | ||
38 | + "postcss-use": "^2.0.2", | ||
39 | + "precss": "^1.4.0", | ||
40 | + "webpack": "^1.13.0", | ||
41 | + "webpack-dev-server": "^1.14.1", | ||
42 | + "webpack-stream": "^3.1.0" | ||
43 | + } | ||
44 | +} |
@@ -7,10 +7,15 @@ | @@ -7,10 +7,15 @@ | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | 8 | ||
9 | const gulp = require('gulp'); | 9 | const gulp = require('gulp'); |
10 | +const gutil = require('gulp-util'); | ||
10 | const postcss = require('gulp-postcss'); | 11 | const postcss = require('gulp-postcss'); |
11 | const sourcemaps = require('gulp-sourcemaps'); | 12 | const sourcemaps = require('gulp-sourcemaps'); |
12 | const cssnano = require('gulp-cssnano'); | 13 | const cssnano = require('gulp-cssnano'); |
13 | 14 | ||
15 | +const webpack = require('webpack'); | ||
16 | +const webpackDevServer = require('webpack-dev-server'); | ||
17 | +const webpackConfig = require('./webpack.config.js'); | ||
18 | + | ||
14 | const env = { | 19 | const env = { |
15 | dev: Symbol('development'), | 20 | dev: Symbol('development'), |
16 | pro: Symbol('production') | 21 | pro: Symbol('production') |
@@ -135,4 +140,34 @@ gulp.task('postcss', ['assets'], () => { | @@ -135,4 +140,34 @@ gulp.task('postcss', ['assets'], () => { | ||
135 | .pipe(postcssPlugin(env.pro)) | 140 | .pipe(postcssPlugin(env.pro)) |
136 | .pipe(cssnano()) | 141 | .pipe(cssnano()) |
137 | .pipe(gulp.dest(dist.css)); | 142 | .pipe(gulp.dest(dist.css)); |
143 | +}); | ||
144 | + | ||
145 | +// webpack dev server | ||
146 | +// gulp.task('webpack-dev-server', () => { | ||
147 | +// var devConfig = Object.assign({}, webpackConfig, { | ||
148 | +// devtool: 'eval', | ||
149 | +// debug: true | ||
150 | +// }); | ||
151 | + | ||
152 | +// new webpackDevServer(webpack(devConfig), { | ||
153 | +// contentBase: '.', | ||
154 | +// publicPath: '/', | ||
155 | +// stats: { | ||
156 | +// colors: true | ||
157 | +// } | ||
158 | +// }).listen(8000, 'localhost', (err) => { | ||
159 | +// if (err) { | ||
160 | +// throw new gutil.PluginError('webpack-dev-server', err); | ||
161 | +// } | ||
162 | +// gutil.log('[webpack-serve]', 'http://localhost:8000/'); | ||
163 | +// }); | ||
164 | +// }); | ||
165 | + | ||
166 | +// webpack compile in pro | ||
167 | +gulp.task('webpack', () => { | ||
168 | + webpack(webpackConfig, (err, stats) => { | ||
169 | + if (err) { | ||
170 | + throw new gutil.PluginError('webpack', err); | ||
171 | + } | ||
172 | + }); | ||
138 | }); | 173 | }); |
public/webpack.config.js
0 → 100644
1 | +/** | ||
2 | + * webpack config | ||
3 | + * @author: xuqi<qi.xu@yoho.cn> | ||
4 | + * @date: 2016/4/25 | ||
5 | + */ | ||
6 | + | ||
7 | +'use strict'; | ||
8 | + | ||
9 | +const webpack = require('webpack'); | ||
10 | +const fs = require('fs'); | ||
11 | +const path = require('path'); | ||
12 | +const _ = require('lodash'); | ||
13 | + | ||
14 | +require('shelljs/global'); | ||
15 | + | ||
16 | +var entries = {}; | ||
17 | + | ||
18 | +//构建各模块子页面JS。生成规则module.page.js | ||
19 | +ls(__dirname + '/js/**/*.page.js').forEach((f) => { | ||
20 | + var dir = _.slice(f.split('/'), -2); //[modulename, xx.page.js] | ||
21 | + | ||
22 | + // Important | ||
23 | + // 生成规则:module.page: './js/module/xx.page.js' | ||
24 | + entries[`${dir[0]}.${dir[1].match(/(.*).page.js/)[1]}`] = `./js/${dir.join('/')}`; | ||
25 | +}); | ||
26 | + | ||
27 | +module.exports = { | ||
28 | + entry: entries, | ||
29 | + output: { | ||
30 | + path: './bundle', | ||
31 | + filename: '[name].js' | ||
32 | + } | ||
33 | +}; |
-
Please register or login to post a comment