improvement: detect dev mode for Svelte compilation

This commit is contained in:
Ondřej Synáček 2020-12-25 09:42:00 +01:00
parent e71f8476bb
commit 06c8a217e0
2 changed files with 7 additions and 2 deletions

View File

@ -8,8 +8,8 @@
"node": "10.15.0"
},
"scripts": {
"build": "npm run clean:build && webpack --config=./webpack.prod.js",
"build:dev": "npm run clean:build && webpack --config=./webpack.dev.js",
"build": "npm run clean:build && NODE_ENV=production webpack --config=./webpack.prod.js",
"build:dev": "npm run clean:build && NODE_ENV=development webpack --config=./webpack.dev.js",
"build:firebase:hosting": "npm run clean:build && NODE_ENV=production NODE_APP=firebase webpack --config=./webpack.prod.js",
"build:firebase:hosting:dev": "npm run clean:build && NODE_ENV=development NODE_APP=firebase webpack --config=./webpack.dev.js",
"clean:build": "rm dist/** || true",

View File

@ -12,6 +12,9 @@ const isFirebaseEnv = process.env.NODE_APP === 'firebase'
const firebaseConfigFilePath = path.join(__dirname, '.firebaserc')
const hasFirebaseConfig = fs.existsSync(firebaseConfigFilePath)
const isDev = process.env.NODE_ENV === 'development'
console.log(`Detected dev mode? ${isDev}`)
if (isFirebaseEnv && hasFirebaseConfig) {
console.info('Prepare build for Firebase hosting')
}
@ -43,6 +46,8 @@ module.exports = {
loader: 'svelte-loader',
options: {
emitCss: false,
hotReload: isDev,
dev: isDev,
},
},
},