修复fite的环境判断
parent
388465842c
commit
3385c4947a
8
index.js
8
index.js
|
@ -18,16 +18,16 @@ const IS_WINDOWS = process.platform === 'win32'
|
||||||
|
|
||||||
const CONFIG_FILE = normalize(join(WORK_SPACE, 'fite.config.js'))
|
const CONFIG_FILE = normalize(join(WORK_SPACE, 'fite.config.js'))
|
||||||
const PROTOCOL = IS_WINDOWS ? 'file://' : ''
|
const PROTOCOL = IS_WINDOWS ? 'file://' : ''
|
||||||
const NODE_VERSION = +process.versions.node.split('.').slice(0, 2).join('.')
|
const NODE_VERSION = process.versions.node.split('.').map(n => +n)
|
||||||
|
|
||||||
let args = process.argv.slice(2)
|
let args = process.argv.slice(2)
|
||||||
let mode = args.shift() || 'prod'
|
let mode = args.shift() || 'prod'
|
||||||
let clean = args.shift() !== '--no-clean'
|
let clean = args.shift() !== '--no-clean'
|
||||||
|
|
||||||
if (NODE_VERSION < 16.6) {
|
if (NODE_VERSION[0] < 16 || (NODE_VERSION[0] === 16 && NODE_VERSION[1] < 6)) {
|
||||||
console.log(red('Error: 你当前的环境不满足 Vue-live 构建工具的要求'))
|
console.log(red('Error: 你当前的环境不满足 fite 构建工具的要求'))
|
||||||
console.log(
|
console.log(
|
||||||
'Vue-live 需要Node.js版本在 %s 以上, \n你当前的Node.js版本为: %s',
|
'fite 需要Node.js版本在 %s 以上, \n你当前的Node.js版本为: %s',
|
||||||
blue('v16.6.0'),
|
blue('v16.6.0'),
|
||||||
red(process.version),
|
red(process.version),
|
||||||
'\n\n'
|
'\n\n'
|
||||||
|
|
|
@ -18,14 +18,14 @@ export function friendlyErrors(pathname, ext = '') {
|
||||||
export function createHmrScript(legacy) {
|
export function createHmrScript(legacy) {
|
||||||
return `
|
return `
|
||||||
!(function vue_live_hmr(){
|
!(function vue_live_hmr(){
|
||||||
var ws = new WebSocket(\`ws\${location.protocol === 'https:' ? 's' : ''}://\${location.host}/ws-vue-live\`)
|
var ws = new WebSocket(\`ws\${location.protocol === 'https:' ? 's' : ''}://\${location.host}/ws-fite-hmr\`)
|
||||||
|
|
||||||
ws.addEventListener('open', function (r) {
|
ws.addEventListener('open', function (r) {
|
||||||
if(vue_live_hmr.closed){
|
if(vue_live_hmr.closed){
|
||||||
delete vue_live_hmr.closed
|
delete vue_live_hmr.closed
|
||||||
location.reload()
|
location.reload()
|
||||||
}
|
}
|
||||||
console.log('vue-live hmr ready...')
|
console.log('fite hmr ready...')
|
||||||
})
|
})
|
||||||
|
|
||||||
ws.addEventListener('close', function(){
|
ws.addEventListener('close', function(){
|
||||||
|
|
|
@ -11,7 +11,7 @@ class WebSocket {
|
||||||
|
|
||||||
constructor(server) {
|
constructor(server) {
|
||||||
if (server.listening) {
|
if (server.listening) {
|
||||||
let conn = new WebSocketServer({ server, path: '/ws-vue-live' })
|
let conn = new WebSocketServer({ server, path: '/ws-fite-hmr' })
|
||||||
conn.on('connection', ws => {
|
conn.on('connection', ws => {
|
||||||
this.#ws = ws
|
this.#ws = ws
|
||||||
// ws.on('message', data => {
|
// ws.on('message', data => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "fite",
|
"name": "fite",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "1.1.5",
|
"version": "1.1.6",
|
||||||
"bin": {
|
"bin": {
|
||||||
"fite": "index.js"
|
"fite": "index.js"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue