Last active
March 3, 2017 17:46
-
-
Save jrop/d2157a3e3b8210a324d1 to your computer and use it in GitHub Desktop.
Simple gulpfile.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": [ "latest", "react" ], | |
"plugins": [ "transform-runtime" ] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
env: | |
es6: true | |
node: true | |
browser: true | |
parserOptions: | |
sourceType: module | |
parser: babel-eslint | |
plugins: [react] | |
rules: | |
react/jsx-uses-react: warn | |
react/jsx-uses-vars: warn | |
react/jsx-no-undef: error | |
no-alert: off | |
no-array-constructor: off | |
no-bitwise: off | |
no-caller: off | |
no-case-declarations: error | |
no-catch-shadow: off | |
no-class-assign: error | |
no-cond-assign: error | |
no-confusing-arrow: off | |
no-console: warn | |
no-const-assign: error | |
no-constant-condition: error | |
no-continue: off | |
no-control-regex: error | |
no-debugger: error | |
no-delete-var: error | |
no-div-regex: off | |
no-dupe-class-members: error | |
no-dupe-keys: error | |
no-dupe-args: error | |
no-duplicate-case: error | |
no-duplicate-imports: off | |
no-else-return: off | |
no-empty: error | |
no-empty-character-class: error | |
no-empty-function: off | |
no-empty-pattern: error | |
no-eq-null: off | |
no-eval: off | |
no-ex-assign: error | |
no-extend-native: off | |
no-extra-bind: off | |
no-extra-boolean-cast: error | |
no-extra-label: off | |
no-extra-parens: off | |
no-extra-semi: error | |
no-fallthrough: error | |
no-floating-decimal: off | |
no-func-assign: error | |
no-implicit-coercion: off | |
no-implicit-globals: off | |
no-implied-eval: off | |
no-inline-comments: off | |
no-inner-declarations: error | |
no-invalid-regexp: error | |
no-invalid-this: off | |
no-irregular-whitespace: warn | |
no-iterator: off | |
no-label-var: off | |
no-labels: off | |
no-lone-blocks: off | |
no-lonely-if: off | |
no-loop-func: off | |
no-mixed-requires: off | |
no-mixed-spaces-and-tabs: warn | |
linebreak-style: off | |
no-multi-spaces: warn | |
no-multi-str: off | |
no-multiple-empty-lines: off | |
no-native-reassign: off | |
no-negated-condition: off | |
no-negated-in-lhs: error | |
no-nested-ternary: off | |
no-new: off | |
no-new-func: off | |
no-new-object: off | |
no-new-require: off | |
no-new-symbol: error | |
no-new-wrappers: off | |
no-obj-calls: error | |
no-octal: error | |
no-octal-escape: off | |
no-param-reassign: off | |
no-path-concat: off | |
no-plusplus: off | |
no-process-env: off | |
no-process-exit: off | |
no-proto: off | |
no-redeclare: error | |
no-regex-spaces: error | |
no-restricted-globals: off | |
no-restricted-imports: off | |
no-restricted-modules: off | |
no-restricted-syntax: off | |
no-return-assign: off | |
no-script-url: off | |
no-self-assign: error | |
no-self-compare: off | |
no-sequences: off | |
no-shadow: off | |
no-shadow-restricted-names: off | |
no-whitespace-before-property: off | |
no-spaced-func: off | |
no-sparse-arrays: error | |
no-sync: off | |
no-ternary: off | |
no-trailing-spaces: warn | |
no-this-before-super: error | |
no-throw-literal: off | |
no-undef: error | |
no-undef-init: off | |
no-undefined: off | |
no-unexpected-multiline: error | |
no-underscore-dangle: off | |
no-unmodified-loop-condition: off | |
no-unneeded-ternary: off | |
no-unreachable: error | |
no-unused-expressions: off | |
no-unused-labels: error | |
no-unused-vars: warn | |
no-use-before-define: off | |
no-useless-call: off | |
no-useless-concat: off | |
no-useless-constructor: off | |
no-void: off | |
no-var: warn | |
no-warning-comments: warn | |
no-with: off | |
no-magic-numbers: off | |
array-bracket-spacing: [warn, never] | |
array-callback-return: off | |
arrow-body-style: off | |
arrow-parens: off | |
arrow-spacing: [warn, {before: true, after: true}] | |
accessor-pairs: off | |
block-scoped-var: off | |
block-spacing: off | |
brace-style: off | |
callback-return: off | |
camelcase: off | |
comma-dangle: [warn, always-multiline] | |
comma-spacing: off | |
comma-style: off | |
complexity: [off, warn] | |
computed-property-spacing: off | |
consistent-return: off | |
consistent-this: off | |
constructor-super: error | |
curly: off | |
default-case: off | |
dot-location: off | |
dot-notation: off | |
eol-last: warn | |
eqeqeq: off | |
func-names: off | |
func-style: off | |
generator-star-spacing: off | |
global-require: off | |
guard-for-in: off | |
handle-callback-err: off | |
id-length: off | |
indent: [warn, tab] | |
init-declarations: off | |
jsx-quotes: off | |
key-spacing: off | |
keyword-spacing: off | |
lines-around-comment: off | |
max-depth: off | |
max-len: off | |
max-nested-callbacks: off | |
max-params: off | |
max-statements: off | |
new-cap: off | |
new-parens: off | |
newline-after-var: off | |
newline-before-return: off | |
newline-per-chained-call: off | |
object-curly-spacing: [warn, never] | |
object-shorthand: off | |
one-var: off | |
one-var-declaration-per-line: off | |
operator-assignment: off | |
operator-linebreak: off | |
padded-blocks: off | |
prefer-arrow-callback: off | |
prefer-const: warn | |
prefer-reflect: off | |
prefer-rest-params: off | |
prefer-spread: off | |
prefer-template: off | |
quote-props: off | |
quotes: [warn, single, {avoidEscape: true}] | |
radix: off | |
id-match: off | |
id-blacklist: off | |
require-jsdoc: off | |
require-yield: off | |
semi: [warn, never] | |
semi-spacing: off | |
sort-vars: off | |
sort-imports: off | |
space-before-blocks: warn | |
space-before-function-paren: [warn, {anonymous: always, named: never}] | |
space-in-parens: off | |
space-infix-ops: off | |
space-unary-ops: off | |
spaced-comment: warn | |
strict: [error, global] | |
template-curly-spacing: off | |
use-isnan: error | |
valid-jsdoc: off | |
valid-typeof: error | |
vars-on-top: off | |
wrap-iife: off | |
wrap-regex: off | |
yield-star-spacing: off | |
yoda: off |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npm i --save-dev gulp gulp-autoprefixer gulp-babel del gulp-less lodash.once webpack | |
'use strict' | |
const gulp = require('gulp') | |
const autoprefixer = require('gulp-autoprefixer') | |
const babel = require('gulp-babel') | |
const del = require('del') | |
const less = require('gulp-less') | |
const plumber = require('gulp-plumber') | |
const webpack = require('webpack') | |
gulp.task('default', [ 'css', 'js:client', 'js:server' ]) | |
gulp.task('css', () => gulp.src([ 'src/public/css/**/*.less', '!**/lib/**/*.*' ]) | |
.pipe(plumber()) | |
.pipe(less()) | |
.pipe(autoprefixer()) | |
.pipe(gulp.dest('cordova/www/css'))) | |
const compiler = webpack(require('./webpack.config.js')) | |
const reporter = (err, stats) => console.log(stats.toString('normal')) | |
if (process.argv.includes('watch')) { | |
gulp.task('js:public') | |
compiler.watch({}, reporter) | |
} else { | |
gulp.task('js:public', done => compiler.run((err, stats) => { | |
reporter(err, stats) | |
done(err) | |
})) | |
} | |
gulp.task('js:server', () => gulp.src('src/main/**/*.js') | |
.pipe(plumber()) | |
.pipe(babel()) | |
.pipe(gulp.dest('build'))) | |
gulp.task('watch', [ 'default' ], function () { | |
gulp.watch('src/public/css/**/*.less', [ 'css' ]) | |
gulp.watch('src/public/js/**/*.js', [ 'js:client' ]) | |
gulp.watch('src/main/**/*.js', [ 'js:server' ]) | |
}) | |
gulp.task('clean', () => Promise.all([ | |
del('cordova/www/css'), | |
del('cordova/www/js'), | |
del('build'), | |
])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const glob = require('globby').sync | |
const path = require('path') | |
const webpack = require('webpack') | |
const NotifierPlugin = require('webpack-notifier') | |
const Visualizer = require('webpack-visualizer-plugin') | |
const entry = { } | |
glob([ 'src/public/js/**/*.js', '!**/lib/**/*.js' ]) | |
.forEach(f => entry[path.relative('src/public/js', f)] = path.resolve(process.cwd(), f)) // eslint-disable-line no-return-assign | |
const PROD = process.env.NODE_ENV == 'production' | |
const PROD_PLUGINS = [ new webpack.optimize.UglifyJsPlugin({ | |
comments: false, | |
compress: { warnings: false }, | |
minimize: true, | |
}), new webpack.DefinePlugin({ | |
'process.env': { | |
NODE_ENV: '"production"', | |
}, | |
}) ] | |
const DEV_PLUGINS = [ new Visualizer() ] | |
module.exports = { | |
devtool: PROD ? '' : '#source-map', | |
entry, | |
output: { | |
path: `${__dirname}/build/public/js`, | |
filename: '[name]', | |
}, | |
module: { | |
loaders: [ { | |
test: /\.js$/, | |
loader: 'babel-loader', | |
exclude: /node_modules/, | |
}, { | |
test: /\.scss$/, | |
loader: 'style!css?modules&localIdentName=[name]_[local]_[hash:base64:5]!sass', | |
} ], | |
}, | |
plugins: [ | |
new webpack.optimize.CommonsChunkPlugin({ | |
name: 'common', | |
filename: 'common.js', | |
minChunks: 2, | |
}), | |
new NotifierPlugin({ | |
alwaysNotify: false, | |
}), | |
].concat(PROD ? PROD_PLUGINS : DEV_PLUGINS), | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment