|
|
@ -9,6 +9,9 @@
|
|
|
|
const colors = require('colors/safe')
|
|
|
|
const colors = require('colors/safe')
|
|
|
|
const fsbx = require('fuse-box')
|
|
|
|
const fsbx = require('fuse-box')
|
|
|
|
const nodemon = require('nodemon')
|
|
|
|
const nodemon = require('nodemon')
|
|
|
|
|
|
|
|
const babel = require('babel-core')
|
|
|
|
|
|
|
|
const uglify = require('uglify-es')
|
|
|
|
|
|
|
|
const fs = require('fs-extra')
|
|
|
|
|
|
|
|
|
|
|
|
// ======================================================
|
|
|
|
// ======================================================
|
|
|
|
// Parse cmd arguments
|
|
|
|
// Parse cmd arguments
|
|
|
@ -90,7 +93,7 @@ globalTasks.then(() => {
|
|
|
|
fsbx.VuePlugin(),
|
|
|
|
fsbx.VuePlugin(),
|
|
|
|
['.scss', fsbx.SassPlugin({ outputStyle: (dev) ? 'nested' : 'compressed' }), fsbx.CSSPlugin()],
|
|
|
|
['.scss', fsbx.SassPlugin({ outputStyle: (dev) ? 'nested' : 'compressed' }), fsbx.CSSPlugin()],
|
|
|
|
fsbx.BabelPlugin({ comments: false, presets: ['es2015'] }),
|
|
|
|
fsbx.BabelPlugin({ comments: false, presets: ['es2015'] }),
|
|
|
|
fsbx.JSONPlugin(),
|
|
|
|
fsbx.JSONPlugin()
|
|
|
|
/* !dev && fsbx.QuantumPlugin({
|
|
|
|
/* !dev && fsbx.QuantumPlugin({
|
|
|
|
target: 'browser',
|
|
|
|
target: 'browser',
|
|
|
|
uglify: true,
|
|
|
|
uglify: true,
|
|
|
@ -109,7 +112,7 @@ globalTasks.then(() => {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}) */
|
|
|
|
}) */
|
|
|
|
!dev && fsbx.UglifyESPlugin()
|
|
|
|
// !dev && fsbx.UglifyESPlugin()
|
|
|
|
],
|
|
|
|
],
|
|
|
|
debug: false,
|
|
|
|
debug: false,
|
|
|
|
log: true
|
|
|
|
log: true
|
|
|
@ -140,6 +143,46 @@ globalTasks.then(() => {
|
|
|
|
watch: (args.d) ? ['server'] : ['server/configure.js'],
|
|
|
|
watch: (args.d) ? ['server'] : ['server/configure.js'],
|
|
|
|
env: { 'NODE_ENV': 'development' }
|
|
|
|
env: { 'NODE_ENV': 'development' }
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
console.info(colors.yellow.bold('\nTranspiling vendor bundle...'))
|
|
|
|
|
|
|
|
let appCode = babel.transform(fs.readFileSync('./assets/js/app.js', 'utf8'), {
|
|
|
|
|
|
|
|
babelrc: false,
|
|
|
|
|
|
|
|
compact: false,
|
|
|
|
|
|
|
|
filename: 'app.js',
|
|
|
|
|
|
|
|
plugins: ['transform-object-assign']
|
|
|
|
|
|
|
|
}).code
|
|
|
|
|
|
|
|
let vendorCode = babel.transform(fs.readFileSync('./assets/js/vendor.js', 'utf8'), {
|
|
|
|
|
|
|
|
babelrc: false,
|
|
|
|
|
|
|
|
comments: false,
|
|
|
|
|
|
|
|
compact: false,
|
|
|
|
|
|
|
|
filename: 'vendor.js',
|
|
|
|
|
|
|
|
plugins: [
|
|
|
|
|
|
|
|
'transform-es2015-arrow-functions',
|
|
|
|
|
|
|
|
'transform-es2015-block-scoped-functions',
|
|
|
|
|
|
|
|
'transform-es2015-block-scoping',
|
|
|
|
|
|
|
|
'transform-es2015-classes',
|
|
|
|
|
|
|
|
'transform-es2015-computed-properties',
|
|
|
|
|
|
|
|
'transform-es2015-destructuring',
|
|
|
|
|
|
|
|
'transform-es2015-duplicate-keys',
|
|
|
|
|
|
|
|
'transform-es2015-for-of',
|
|
|
|
|
|
|
|
'transform-es2015-function-name',
|
|
|
|
|
|
|
|
'transform-es2015-literals',
|
|
|
|
|
|
|
|
'transform-es2015-object-super',
|
|
|
|
|
|
|
|
'transform-es2015-parameters',
|
|
|
|
|
|
|
|
'transform-es2015-shorthand-properties',
|
|
|
|
|
|
|
|
'transform-es2015-spread',
|
|
|
|
|
|
|
|
'transform-es2015-sticky-regex',
|
|
|
|
|
|
|
|
'transform-es2015-template-literals',
|
|
|
|
|
|
|
|
'transform-es2015-typeof-symbol',
|
|
|
|
|
|
|
|
'transform-es2015-unicode-regex'
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}).code
|
|
|
|
|
|
|
|
console.info(colors.yellow.bold('Minifing bundles...'))
|
|
|
|
|
|
|
|
fs.writeFileSync('./assets/js/vendor.js', uglify.minify(vendorCode).code, 'utf8')
|
|
|
|
|
|
|
|
fs.writeFileSync('./assets/js/app.js', uglify.minify(appCode).code, 'utf8')
|
|
|
|
|
|
|
|
fs.writeFileSync('./assets/js/configure.js', uglify.minify(fs.readFileSync('./assets/js/configure.js', 'utf8')).code, 'utf8')
|
|
|
|
|
|
|
|
console.info(colors.green.bold('\nBUILD SUCCEEDED.'))
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
}).catch(err => {
|
|
|
|
console.error(colors.red(' X Bundle compilation failed! ' + err.message))
|
|
|
|
console.error(colors.red(' X Bundle compilation failed! ' + err.message))
|
|
|
|