[UI Framework] Add uiFramework:build task. (#11402)

* Add uiFramework:build task.
This commit is contained in:
CJ Cenizal 2017-04-27 11:41:36 -07:00 committed by GitHub
parent 36ccbc1465
commit 1f76e7508e
3 changed files with 36 additions and 3 deletions

View file

@ -63,7 +63,8 @@
"mocha": "mocha",
"mocha:debug": "mocha --debug-brk",
"sterilize": "grunt sterilize",
"uiFramework:start": "grunt uiFramework:start"
"uiFramework:start": "grunt uiFramework:start",
"uiFramework:build": "grunt uiFramework:build"
},
"repository": {
"type": "git",

View file

@ -4,8 +4,40 @@ import postcssConfig from '../src/optimize/postcss.config';
import chokidar from 'chokidar';
import debounce from 'lodash/function/debounce';
const platform = require('os').platform();
const isPlatformWindows = /^win/.test(platform);
module.exports = function (grunt) {
grunt.registerTask('uiFramework:build', function () {
const done = this.async();
const serverCmd = {
cmd: isPlatformWindows ? '.\\node_modules\\.bin\\webpack.cmd' : './node_modules/.bin/webpack',
args: [
'-p',
'--config=ui_framework/doc_site/webpack.config.js',
],
opts: { stdio: 'inherit' }
};
const uiFrameworkServerBuild = new Promise((resolve, reject) => {
grunt.util.spawn(serverCmd, (error, result, code) => {
if (error || code !== 0) {
const message = result.stderr || result.stdout;
grunt.log.error(message);
return reject();
}
grunt.log.writeln(result);
resolve();
});
});
uiFrameworkServerBuild.then(done);
});
grunt.registerTask('uiFramework:start', function () {
const done = this.async();
Promise.all([uiFrameworkWatch(), uiFrameworkServerStart()]).then(done);
@ -13,7 +45,7 @@ module.exports = function (grunt) {
function uiFrameworkServerStart() {
const serverCmd = {
cmd: /^win/.test(platform) ? '.\\node_modules\\.bin\\webpack-dev-server.cmd' : './node_modules/.bin/webpack-dev-server',
cmd: isPlatformWindows ? '.\\node_modules\\.bin\\webpack-dev-server.cmd' : './node_modules/.bin/webpack-dev-server',
args: [
'--config=ui_framework/doc_site/webpack.config.js',
'--hot ',

View file

@ -8,7 +8,7 @@ module.exports = {
},
output: {
path: path.resolve(__dirname, 'ui_framework/doc_site/build'),
path: path.resolve(__dirname, 'build'),
filename: 'bundle.js'
},