Skip to content

Instantly share code, notes, and snippets.

@FbN
Last active July 9, 2019 14:43
Show Gist options
  • Save FbN/2769ead4e6369a7b4bd3f6c8a38cd7bf to your computer and use it in GitHub Desktop.
Save FbN/2769ead4e6369a7b4bd3f6c8a38cd7bf to your computer and use it in GitHub Desktop.
Browsersync config
const browserSyncFactory = require('browser-sync')
const history = require('connect-history-api-fallback')
const babel = require("@babel/core")
const fs = require('fs')
const browserSync = browserSyncFactory.create()
browserSync.watch('app/**/*').on("change", browserSync.reload)
browserSync.watch('.tmp/**/*').on("change", browserSync.reload)
browserSync.watch('views/*.jsx', function (event, file) {
const {code, map} = babel.transformFileSync(file)
fs.writeFileSync('.tmp/js/'+file.replace('.jsx','.js'), code+"/n"+map)
})
browserSync.init({
notify: false,
server: {
baseDir: ['.tmp', 'app'],
routes: {
'/web_modules': 'web_modules'
}
},
middleware: [history()]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment