summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/gulpfile.js
diff options
context:
space:
mode:
authorAvi Ziv <avi.ziv@amdocs.com>2017-07-18 19:45:38 +0300
committerAvi Ziv <avi.ziv@amdocs.com>2017-07-18 19:45:38 +0300
commitb8e2faf476202b6ffe61bc3a9a37df1304881d40 (patch)
treef78b8c0517d8e16c5ae610bf8b49f68ea8a312a1 /openecomp-ui/gulpfile.js
parent75aacbbe1acf78fa53378f07f0a8c7769449a17e (diff)
[SDC] Onboarding 1710 rebase.
Change-Id: If3b6b81d221fde13908f1e8160db6f7d9433c535 Signed-off-by: Avi Ziv <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-ui/gulpfile.js')
-rw-r--r--openecomp-ui/gulpfile.js86
1 files changed, 56 insertions, 30 deletions
diff --git a/openecomp-ui/gulpfile.js b/openecomp-ui/gulpfile.js
index 2cad6d8520..eb755a2be0 100644
--- a/openecomp-ui/gulpfile.js
+++ b/openecomp-ui/gulpfile.js
@@ -5,9 +5,11 @@ let gulpHelpers = require('gulp-helpers');
let replace = require('gulp-replace');
let taskMaker = gulpHelpers.taskMaker(gulp);
let runSequence = gulpHelpers.framework('run-sequence');
-let i18nTask = require('./tools/gulp/tasks/i18n');
-let prodTask = require('./tools/gulp/tasks/prod');
let gulpCssUsage = require('gulp-css-usage').default;
+
+let prodTask = require('./tools/gulp/tasks/prod');
+let i18nTask = require('./tools/gulp/tasks/i18n.js');
+
let jsonConfig = {
"appContextPath" : "/onboarding"
};
@@ -15,48 +17,60 @@ let jsonConfig = {
try {
jsonConfig = require('./src/sdc-app/config/config.json');
} catch (e) {
- console.log('could not load config. using deault value instead');
+ console.log('could not load config. using default value instead');
}
const appName = 'onboarding';
const dist = 'dist';
const path = {
- jetty: './webapp-onboarding/WEB-INF/jetty-web.xml',
- appinf: './webapp-onboarding/**/*.*',
- appinf_output: dist + '/webapp-onboarding',
- locales: dist + '/i18n/',
- output: dist,
+ // inputs
json: './src/**/*.json',
index: './src/index.html',
heat: './src/heat.html',
scss: './resources/scss/**/*.scss',
- css: dist + '/css',
+ i18nBundles: './src/nfvo-utils/i18n/*.json',
svgSrc: './resources/images/svg/*.svg',
+ appinf: './webapp-onboarding/**/*.*',
+ jetty: './webapp-onboarding/WEB-INF/jetty-web.xml',
+ srcDir: './src/',
+ // output
+ output: dist,
+ css: dist + '/css',
svg: dist + '/resources/images/svg',
- war: [dist + '/index.html', dist + '/punch-outs_en.js', dist + '/**/*.{css,png,svg,eot,ttf,woff,woff2,otf}', dist + '/**/*(config.json|locale.json)', 'tools/gulp/deployment/**', dist + '/webapp-onboarding/**'],
- heatWar: [dist + '/heat.html', dist + '/heat-validation_en.js', dist + '/**/*.{css,png,svg,eot,ttf,woff,woff2,otf}', dist + '/**/*(config.json|locale.json)', 'webapp-heat-validation/**'],
+ appinf_output: dist + '/webapp-onboarding',
+ // war
+ war: [dist + '/index.html', dist + '/punch-outs*.js', dist + '/**/*.{css,png,svg,eot,ttf,woff,woff2,otf}', dist + '/**/*(config.json)', dist + '/webapp-onboarding/**'],
+ heatWar: [dist + '/heat.html', dist + '/heat-validation_en.js', dist + '/**/*.{css,png,svg,eot,ttf,woff,woff2,otf}', dist + '/**/*(config.json)', 'webapp-heat-validation/**'],
wardest: dist,
+ // storybook
storybookFonts: './.storybook/fonts/*',
storybookDist: './.storybook-dist',
storybookResources: './.storybook/resources/onboarding/resources/images/svg',
storybookDistResources: './.storybook-dist/onboarding/resources/images/svg'
};
-
+// cleans up the output directory
taskMaker.defineTask('clean', {taskName: 'clean', src: path.output});
+// copies for all relevant files to the output directory
taskMaker.defineTask('copy', {taskName: 'copy-json', src: path.json, dest: path.output, changed: {extension: '.json'}});
taskMaker.defineTask('copy', {taskName: 'copy-index.html', src: path.index, dest: path.output, rename: 'index.html'});
taskMaker.defineTask('copy', {taskName: 'copy-heat.html', src: path.heat, dest: path.output, rename: 'heat.html'});
taskMaker.defineTask('copy', {taskName: 'copy-svg', src: path.svgSrc, dest: path.svg});
-//TODO: delete this task after gulp-css-usage support for SCSS files
-taskMaker.defineTask('sass', {taskName: 'sass', src: path.scss, dest: path.css, config: {outputStyle: 'compressed'}});
-taskMaker.defineTask('compress', {taskName: 'compress-war', src: path.war, filename: appName + '.war', dest: path.wardest});
-taskMaker.defineTask('compress', {taskName: 'compress-heat-war', src: path.heatWar, filename: 'heat-validation.war', dest: path.wardest});
-taskMaker.defineTask('watch', {taskName: 'watch-stuff', src: [path.json, path.index, path.heat], tasks: ['copy-stuff']});
taskMaker.defineTask('copy', {taskName: 'copy-storybook-fonts', src: path.storybookFonts, dest: path.storybookDist});
taskMaker.defineTask('copy', {taskName: 'copy-storybook-resources', src: path.svgSrc, dest: path.storybookResources});
taskMaker.defineTask('copy', {taskName: 'copy-storybook-resources-prod', src: path.svgSrc, dest: path.storybookDistResources});
+// used for compressing war files
+taskMaker.defineTask('compress', {taskName: 'compress-war', src: path.war, filename: appName + '.war', dest: path.wardest});
+taskMaker.defineTask('compress', {taskName: 'compress-heat-war', src: path.heatWar, filename: 'heat-validation.war', dest: path.wardest});
+// used for watching for changes for test
+taskMaker.defineTask('watch', {taskName: 'watch-stuff', src: [path.json, path.index, path.heat], tasks: ['copy-stuff']});
+
+
+//TODO: delete this task after gulp-css-usage support for SCSS files
+taskMaker.defineTask('sass', {taskName: 'sass', src: path.scss, dest: path.css, config: {outputStyle: 'compressed'}});
+
+// update the app-context for the web-xml file to the value from the config
gulp.task('app-context', function(){
gulp.src([path.appinf])
.pipe(gulp.dest(path.appinf_output))
@@ -66,22 +80,17 @@ gulp.task('app-context', function(){
.pipe(gulp.dest(path.appinf_output + '/WEB-INF'));
})
});
-
+// aggregates all copy tasks
gulp.task('copy-stuff', callback => runSequence(['copy-json', 'copy-index.html', 'copy-heat.html', 'copy-svg', 'app-context'], callback));
-gulp.task('i18n', () =>
- i18nTask({outputPath: path.output, localesPath: path.locales, lang: 'en'}).catch(err => {
- console.log('i18n Task : Error! ', err);
- throw err;
- })
-);
-
-gulp.task('dev', callback => runSequence('clean', ['i18n', 'copy-stuff'], callback));
-gulp.task('build', callback => runSequence('clean', ['copy-stuff', 'i18n'], 'prod', ['compress-war', 'compress-heat-war'], callback));
-
+// minimum build for dev
+gulp.task('dev', callback => runSequence('clean', 'copy-stuff', callback));
+// build procedure for war file
+gulp.task('build', callback => runSequence('clean', 'copy-stuff', 'prod', ['compress-war', 'compress-heat-war'], callback));
+// default build is set to 'dev'
gulp.task('default', ['dev']);
-
-gulp.task('prod', () => prodTask({outDir: path.output})
+// creating the webpack tasks for the production build
+gulp.task('prod', () => prodTask({outDir: path.output, i18nBundles : path.i18nBundles})
.catch(err => {
if (err && err.stack) {
console.error(err, err.stack);
@@ -90,7 +99,12 @@ gulp.task('prod', () => prodTask({outDir: path.output})
})
);
+/***
+ * T O O L S . N O T P A R T O F B U I L D
+ */
+// this is used to manually run on the sass files to check which classes are never used. not run as part of build.
+// can be run as npm task
gulp.task('gulp-css-usage', () => {
return gulp.src('src/**/*.jsx').pipe(gulpCssUsage({css: path.css + '/style.css', babylon: ['objectRestSpread']}));
});
@@ -99,3 +113,15 @@ gulp.task('css-usage', () => {
runSequence('sass', 'gulp-css-usage');
});
+
+gulp.task('static-keys-bundle', () => i18nTask({outDir: path.output, srcDir: path.srcDir})
+ .catch(err => {
+ throw new Error('static-keys-bundle FAILED');
+ })
+);
+
+gulp.task('static-keys-bundle-with-report', () => i18nTask({outDir: path.output, srcDir: path.srcDir, i18nBundles : path.i18nBundles })
+ .catch(err => {
+ throw new Error('static-keys-bundle FAILED');
+ })
+);