Create a gist now

Instantly share code, notes, and snippets.

@AtsushiM /.babelrc
Last active Mar 23, 2017

What would you like to do?
Bye Bye Sprockets vol2: 設定ファイル
{
"plugins": ["transform-runtime", "babel-plugin-transform-flow-strip-types"],
"presets": ["latest"]
}
{
"parser": "babel-eslint",
"plugins": [
"flowtype"
],
"extends": [
"eslint:recommended",
"plugin:flowtype/recommended",
],
"rules": {
...
"flowtype/require-valid-file-annotation": [ 2, "always" ],
},
"env": {
"browser": true,
"es6": true,
"jquery": true,
"node": true,
},
"globals": {
...
},
}
[ignore]
.*/node_modules/gulp-flowtype/.*
[include]
./node_modules/
[libs]
./frontend/assets/decls/
[options]
import gulp from 'gulp';
import del from 'del';
import runSequence from 'run-sequence';
import coffee from 'gulp-coffee';
import browserify from 'browserify';
import babelify from 'babelify';
import source from 'vinyl-source-stream';
import karma from 'karma';
import sasslint from 'gulp-sass-lint';
import eslint from 'gulp-eslint';
import flow from 'gulp-flowtype';
let path_front = './frontend/assets/source/',
path_cache = `${path_front}_cache/`,
path_app = './app/assets/';
gulp.task('coffee-cache-clean', (cb) => {
return del([ `${path_cache}javascripts/**.*` ]), cb);
});
gulp.task('coffee-compile', (cb) => {
gulp.src([ `${path_front}coffeescript/**.*` ])
.pipe(plumber())
.pipe(coffee({
bare: true
}))
.pipe(gulp.dest(`${path_cache}javascripts/`))
.on('end', cb);
});
gulp.task('coffee', (cb) => {
return runSequence('coffee-cache-clean', 'coffee-compile', cb);
});
gulp.task('coffee-babel', (cb) => {
return runSequence('coffee', 'babel', cb);
});
gulp.task('babel', (cb) => {
browserify({ entries: `${path_front}es/main.js` })
.transform(babelify)
.bundle()
.on('error', function(err) {
console.log(err.toString());
this.emit('end');
})
.pipe(source('main.babel.bundle.js'))
.pipe(gulp.dest(`${path_app}javascripts/`))
.on('end', cb);
});
gulp.task('spec', (cb) => {
new karma.Server({
configFile: `${__dirname}/karma.conf.js`,
singleRun: true,
browsers: ['PhantomJS'],
}, cb).start();
});
gulp.task('eslint', () => {
return gulp.src([ `${path_front}es/**/*.js` ])
.pipe(plumber())
.pipe(eslint())
.pipe(eslint.format())
;
});
gulp.task('flowtype', () => {
return gulp.src([ `${path_front}es/**/*.js` ])
.pipe(plumber())
.pipe(flow())
;
});
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['browserify', 'mocha', 'chai', 'sinon'],
files: [
...
'frontend/spec/**/*_spec.js',
],
exclude: [],
preprocessors: {
'frontend/spec/**/*_spec.js': ['browserify']
},
browserify: {
debug: true,
transform: [ 'babelify']
},
reporters: ['spec'],
browsers: ['Chrome', 'Safari'],
singleRun: true,
concurrency: Infinity
})
}
{
...
"scripts": {
"gulp": "gulp",
"test": "karma start",
"flow": "flow",
"eslint": "eslint ./frontend/assets/source/es/"
},
"dependencies": {
"babel-plugin-transform-flow-strip-types": "^6.21.0",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-latest": "^6.16.0",
"babel-runtime": "^6.18.0",
"babelify": "^7.3.0",
"browserify": "^13.1.1",
"del": "^2.2.2",
"flow-bin": "^0.37.0",
"gulp": "^3.9.1",
"gulp-coffee": "^2.3.3",
"gulp-plumber": "^1.1.0",
"requirejs": "^2.3.2",
"run-sequence": "^1.2.2",
"vinyl-source-stream": "^1.1.0",
"watchify": "^3.7.0"
},
"devDependencies": {
"babel-eslint": "^7.1.1",
"chai": "^3.5.0",
"decafjs": "^0.6.2",
"eslint": "https://registry.npmjs.org/eslint/-/eslint-3.11.1.tgz",
"eslint-plugin-flowtype": "^2.29.1",
"gulp-eslint": "^3.0.1",
"gulp-flowtype": "^1.0.0",
"karma": "^1.3.0",
"karma-browserify": "^5.1.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.0.0",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-safari-launcher": "^1.0.0",
"karma-sinon": "^1.0.5",
"karma-spec-reporter": "0.0.26",
"mocha": "^3.2.0",
"phantomjs-prebuilt": "^2.1.13",
"sinon": "^1.17.6"
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment