Skip to content

Commit

Permalink
Updates dependencies, changes build script to render a separate brows…
Browse files Browse the repository at this point in the history
…er bundle
  • Loading branch information
ffraenz committed Oct 15, 2017
1 parent a6772f9 commit 5723b79
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 29 deletions.
4 changes: 1 addition & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"presets": [
[
"es2015"
]
["env"]
]
}
51 changes: 41 additions & 10 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import autoprefixer from 'gulp-autoprefixer'
import babel from 'rollup-plugin-babel'
import buffer from 'vinyl-buffer'
import cleanCSS from 'gulp-clean-css'
import clone from 'gulp-clone'
import commonJs from 'rollup-plugin-commonjs'
import concat from 'gulp-concat'
import del from 'del'
import esdoc from 'gulp-esdoc-stream'
import gulp from 'gulp'
import mergeStream from 'merge-stream'
import mocha from 'gulp-mocha'
import nodeResolve from 'rollup-plugin-node-resolve'
import rename from 'gulp-rename'
Expand Down Expand Up @@ -57,7 +61,7 @@ gulp.task('test', ['lint-test', 'lint-script'], () => {
}))
})

gulp.task('doc', () => {
gulp.task('doc', ['clean-doc'], () => {
return gulp.src(paths.script + '/**/*.js')
.pipe(esdoc({
destination: paths.doc,
Expand All @@ -72,17 +76,16 @@ gulp.task('doc', () => {

let rollupCache

gulp.task('script', ['lint-script'], () => {
// run module builder and return a stream
const stream = rollup({
gulp.task('script', ['lint-script', 'clean-script'], () => {
let appStream = rollup({
input: paths.script + '/index.js',
external: [
],
plugins: [
babel({
babelrc: false,
presets: [
['es2015', {
['env', {
loose: true,
modules: false
}]
Expand All @@ -109,7 +112,7 @@ gulp.task('script', ['lint-script'], () => {
amd: { id: meta.name }
})

return stream
appStream = appStream
// enable rollup cache
.on('bundle', (bundle) => {
rollupCache = bundle
Expand All @@ -125,9 +128,9 @@ gulp.task('script', ['lint-script'], () => {
})

// set output filename
.pipe(source(meta.name + '.js', paths.src))
.pipe(source(`${meta.name}.js`, paths.src))

// buffer the output, most gulp plugins do not support streams
// buffer the output
.pipe(buffer())

// init sourcemaps with inline sourcemap produced by rollup-stream
Expand All @@ -138,12 +141,28 @@ gulp.task('script', ['lint-script'], () => {
// minify code
.pipe(uglify())

// save result
// create polyfill stream from existing files
let polyfillStream = gulp.src([
'./node_modules/dom4/build/dom4.js',
'./node_modules/babel-polyfill/dist/polyfill.min.js'
], { base: '.' })
.pipe(sourcemaps.init())

// compose library bundle
let libraryBundleStream = appStream.pipe(clone())
.pipe(sourcemaps.write('.'))

// compose browser bundle
let browserBundleStream = mergeStream(polyfillStream, appStream)
.pipe(concat(`${meta.name}-browser.js`))
.pipe(sourcemaps.write('.'))

// save bundles and sourcemaps
return mergeStream(libraryBundleStream, browserBundleStream)
.pipe(gulp.dest(paths.scriptDist))
})

gulp.task('style', () => {
gulp.task('style', ['clean-style'], () => {
return gulp.src(paths.style + '/main.scss')

// init sourcemaps
Expand Down Expand Up @@ -173,6 +192,18 @@ gulp.task('style', () => {
.pipe(gulp.dest(paths.styleDist))
})

gulp.task('clean-style', () => {
return del([paths.styleDist])
})

gulp.task('clean-script', () => {
return del([paths.scriptDist])
})

gulp.task('clean-doc', () => {
return del([paths.doc])
})

gulp.task('watch', () => {
// watch scripts and tests
gulp.watch(
Expand Down
27 changes: 15 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,36 @@
"parser": "babel-eslint"
},
"dependencies": {
"babel-plugin-transform-builtin-extend": "^1.1.2",
"babel-polyfill": "^6.23.0",
"detect-browser": "^1.7.1",
"dom4": "^1.8.5"
"detect-browser": "^1.12.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.25.0",
"babel-eslint": "^7.2.3",
"babel-eslint": "^8.0.1",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-es2015": "^6.24.1",
"babel-plugin-transform-builtin-extend": "^1.1.2",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.0",
"babel-register": "^6.24.1",
"del": "^3.0.0",
"dom4": "^1.8.5",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^4.0.0",
"gulp-clean-css": "^3.5.0",
"gulp-clean-css": "^3.9.0",
"gulp-clone": "^1.0.0",
"gulp-concat": "^2.6.1",
"gulp-esdoc-stream": "^0.1.0",
"gulp-mocha": "^4.3.1",
"gulp-rename": "^1.2.2",
"gulp-sass": "^3.1.0",
"gulp-sourcemaps": "^2.6.0",
"gulp-standard": "^10.0.0",
"gulp-sourcemaps": "^2.6.1",
"gulp-standard": "^10.1.1",
"gulp-uglify": "^3.0.0",
"merge-stream": "^1.0.1",
"normalize-scss": "^7.0.0",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-commonjs": "^8.2.1",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-stream": "^1.20.0",
"rollup-stream": "^1.24.1",
"sass-inline-svg": "^1.0.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ <h2 class="footer__brand"><a href="/">Cryptii</a></h2>
</div>

<!-- script -->
<script async src="dist/script/cryptii.js?v=3"></script>
<script async src="dist/script/cryptii-browser.js?v=3"></script>

</body>
</html>
3 changes: 0 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@

import 'babel-polyfill'
import 'dom4'

import App from './App'
import Browser from './Browser'

Expand Down

0 comments on commit 5723b79

Please sign in to comment.