Last active
July 9, 2019 14:43
-
-
Save FbN/2769ead4e6369a7b4bd3f6c8a38cd7bf to your computer and use it in GitHub Desktop.
Browsersync config
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
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