tiptap/build/examples/server.js

55 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-08-21 05:02:21 +08:00
import path from 'path'
import browserSync from 'browser-sync'
import webpack from 'webpack'
import httpProxyMiddleware from 'http-proxy-middleware'
import webpackDevMiddleware from 'webpack-dev-middleware'
import webpackHotMiddleware from 'webpack-hot-middleware'
2018-09-04 05:44:19 +08:00
import historyApiFallbackMiddleware from 'connect-history-api-fallback'
2018-08-22 16:01:51 +08:00
import config from './webpack.config'
2018-08-21 05:02:21 +08:00
import { sassImport } from './utilities'
import { srcPath, sassImportPath } from './paths'
const bundler = webpack(config)
const middlewares = []
2018-09-04 05:44:19 +08:00
middlewares.push(historyApiFallbackMiddleware())
2018-08-21 05:02:21 +08:00
// add webpack stuff
middlewares.push(webpackDevMiddleware(bundler, {
2018-11-09 05:03:10 +08:00
publicPath: config.output.publicPath,
stats: {
colors: true,
chunks: false,
},
2018-08-21 05:02:21 +08:00
}))
// add hot reloading
middlewares.push(webpackHotMiddleware(bundler))
// start browsersync
2018-08-22 04:40:55 +08:00
const url = 'http://localhost'
2018-08-21 05:02:21 +08:00
const bs = browserSync.create()
const server = bs.init({
2018-11-09 05:03:10 +08:00
server: {
baseDir: `${srcPath}/`,
middleware: middlewares,
},
files: [],
logLevel: 'silent',
open: false,
notify: false,
injectChanges: false,
ghostMode: {
clicks: false,
forms: false,
scroll: false,
},
2018-08-21 05:02:21 +08:00
})
console.log(`${url}:${server.options.get('port')}`)
// sass import
bs.watch(path.join(sassImportPath, '**/!(index|index_sub).scss'), { ignoreInitial: true }, () => {
2018-11-09 05:03:10 +08:00
sassImport(sassImportPath)
2018-08-21 05:02:21 +08:00
})