From 1c45b6eb7003e31426fa4f2be196937f95cb950d Mon Sep 17 00:00:00 2001 From: Gunther Brunner Date: Wed, 4 Jun 2014 18:45:11 +0900 Subject: [PATCH] Starting to add build targets for common status page. --- gulpfile.js | 28 +++++++++++++++++++ lib/roles/app.js | 1 + res/common/status/scripts/entry.js | 0 res/common/status/{ => views}/404.jade | 2 +- .../status/{ => views}/maintenance.jade | 2 +- .../status/{ => views}/partials/styles.jade | 0 res/common/status/webpack.config.js | 12 ++++++++ 7 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 res/common/status/scripts/entry.js rename res/common/status/{ => views}/404.jade (93%) rename res/common/status/{ => views}/maintenance.jade (92%) rename res/common/status/{ => views}/partials/styles.jade (100%) create mode 100644 res/common/status/webpack.config.js diff --git a/gulpfile.js b/gulpfile.js index 9107f82b..79969ff5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,6 +5,7 @@ var jsonlint = require('gulp-jsonlint') var webpack = require('webpack') var ngminPlugin = require('ngmin-webpack-plugin') var webpackConfig = require('./webpack.config.js') +var webpackStatusConfig = require('./res/common/status/webpack.config.js') var gettext = require('gulp-angular-gettext') var jade = require('gulp-jade') var clean = require('gulp-clean') @@ -64,6 +65,7 @@ gulp.task("webpack:build", function (callback) { }), new webpack.optimize.DedupePlugin(), new ngminPlugin(), + // TODO: mangle when ngmin works new webpack.optimize.UglifyJsPlugin({mangle: false}) ) myConfig.devtool = false @@ -80,6 +82,32 @@ gulp.task("webpack:build", function (callback) { }) }) +gulp.task("webpack:others", function (callback) { + var myConfig = Object.create(webpackStatusConfig) + myConfig.plugins = myConfig.plugins.concat( + new webpack.DefinePlugin({ + "process.env": { + "NODE_ENV": JSON.stringify('production') + } + }), + new webpack.optimize.DedupePlugin() +// new ngminPlugin(), +// new webpack.optimize.UglifyJsPlugin({mangle: false}) + ) + myConfig.devtool = false + + webpack(myConfig, function (err, stats) { + if (err) { + throw new gutil.PluginError('webpack:others', err) + } + + gutil.log("[webpack:others]", stats.toString({ + colors: true + })) + callback() + }) +}) + gulp.task('translate', ['jade', 'translate:extract', 'translate:compile']) gulp.task('jade', function () { diff --git a/lib/roles/app.js b/lib/roles/app.js index ae16bf84..f5201d8c 100644 --- a/lib/roles/app.js +++ b/lib/roles/app.js @@ -193,6 +193,7 @@ module.exports = function(options) { list.forEach(function(device) { datautil.normalize(device, req.user) }) + res.json({ success: true , devices: list diff --git a/res/common/status/scripts/entry.js b/res/common/status/scripts/entry.js new file mode 100644 index 00000000..e69de29b diff --git a/res/common/status/404.jade b/res/common/status/views/404.jade similarity index 93% rename from res/common/status/404.jade rename to res/common/status/views/404.jade index ecf77d0d..c7a8866d 100644 --- a/res/common/status/404.jade +++ b/res/common/status/views/404.jade @@ -4,7 +4,7 @@ html title STF Not Found meta(charset='utf-8') meta(name='viewport', content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui') - include partials/styles + include ../partials/styles body(ng-cloak).forofour.bg-danger script(src='/static/bower_components/stf-analytics/analytics.js') div(ng-view) diff --git a/res/common/status/maintenance.jade b/res/common/status/views/maintenance.jade similarity index 92% rename from res/common/status/maintenance.jade rename to res/common/status/views/maintenance.jade index 6c0b91eb..f53d4082 100644 --- a/res/common/status/maintenance.jade +++ b/res/common/status/views/maintenance.jade @@ -4,7 +4,7 @@ html title STF Maintenance meta(charset='utf-8') meta(name='viewport', content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui') - include partials/styles + include ../partials/styles body(ng-cloak).forofour.bg-danger div(ng-view) .forofour-container diff --git a/res/common/status/partials/styles.jade b/res/common/status/views/partials/styles.jade similarity index 100% rename from res/common/status/partials/styles.jade rename to res/common/status/views/partials/styles.jade diff --git a/res/common/status/webpack.config.js b/res/common/status/webpack.config.js new file mode 100644 index 00000000..4c4c6f96 --- /dev/null +++ b/res/common/status/webpack.config.js @@ -0,0 +1,12 @@ +var pathutil = require('./../../../lib/util/pathutil') +var options = require('./../../../webpack.config.js') +var _ = require('lodash') + +module.exports = _.defaults(options, { + entry: pathutil.resource('common/status/scripts/entry.js'), + output: { + path: pathutil.resource('build'), + publicPath: '/static/build/', + filename: 'bundle-status.js' + } +})