39 lines
886 B
JavaScript
39 lines
886 B
JavaScript
'use strict'
|
|
const path = require('path')
|
|
const config = require('../config')
|
|
const packageConfig = require('../package.json')
|
|
|
|
const isDev = process.env.NODE_ENV !== 'production';
|
|
|
|
const assetsPath = (_path) => {
|
|
const assetsSubDirectory = isDev
|
|
? config.dev.assetsSubDirectory
|
|
: config.build.assetsSubDirectory
|
|
|
|
return path.posix.join(assetsSubDirectory, _path)
|
|
}
|
|
|
|
const createNotifierCallback = () => {
|
|
const notifier = require('node-notifier')
|
|
|
|
return (severity, errors) => {
|
|
if (severity !== 'error') return
|
|
|
|
const error = errors[0]
|
|
const filename = error.file && error.file.split('!').pop()
|
|
|
|
notifier.notify({
|
|
title: packageConfig.name,
|
|
message: severity + ': ' + error.name,
|
|
subtitle: filename || '',
|
|
icon: path.join(__dirname, 'logo.png')
|
|
})
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
isDev,
|
|
assetsPath,
|
|
createNotifierCallback
|
|
}
|