Skip to content

Commit

Permalink
Update dev environment (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonguo committed Oct 17, 2018
1 parent 4fb319b commit ae24932
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .babelrc.js
@@ -1,5 +1,7 @@
module.exports = api => {
api.cache(() => process.env.NODE_ENV);
if (api) {
api.cache(() => process.env.NODE_ENV);
}

return {
presets: [
Expand Down
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -10,6 +10,7 @@
"format": "prettier --write \"{src,test}/**/*.js\"",
"format:check": "prettier --list-different \"{src,test}/**/*.js\"",
"build": "rm -rf lib && npx babel src --out-dir lib && npm run dist",
"dev": "gulp dev --gulpfile scripts/gulpfile.js",
"dist-style": "gulp --gulpfile scripts/gulpfile.js && npm run generate-styles",
"dist-map": "NODE_ENV=development webpack --mode development --progress",
"dist-pro": "webpack --mode production --progress",
Expand Down Expand Up @@ -113,6 +114,7 @@
"flow-bin": "^0.81.0",
"glob": "^7.1.2",
"gulp": "^3.9.1",
"gulp-babel": "^8.0.0",
"gulp-less": "^4.0.0",
"gulp-postcss": "^7.0.1",
"gulp-rename": "^1.2.2",
Expand Down
23 changes: 23 additions & 0 deletions scripts/gulpfile.js
Expand Up @@ -4,6 +4,8 @@ const less = require('gulp-less');
const postcss = require('gulp-postcss');
const sourcemaps = require('gulp-sourcemaps');
const rename = require('gulp-rename');
const babel = require('gulp-babel');
const babelrc = require('../.babelrc.js');

const SOURCE_PATH = '../styles';
const DIST_PATH = '../dist/styles';
Expand Down Expand Up @@ -54,3 +56,24 @@ gulp.task('generate-modularized-styles', () => {
gulp.task('default', ['clean'], () => {
gulp.start(['postcss', 'copy-fonts']);
});

gulp.task('babel', () =>
gulp
.src('../src/**/*.js')
.pipe(babel(babelrc()))
.pipe(gulp.dest('../lib'))
);

gulp.task('dev', () => {
gulp.start(['babel']);
gulp.watch('../src/**/*.js', function(event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
const srcPath = `../${event.path.match(/src\/\S*/)[0]}`;
const libPath = srcPath.replace('/src/', '/lib/').replace(/\/[a-z|A-Z]+.js/, '');

gulp
.src(srcPath)
.pipe(babel(babelrc()))
.pipe(gulp.dest(libPath));
});
});

0 comments on commit ae24932

Please sign in to comment.