Last active
May 1, 2017 17:05
-
-
Save sl-digital/664c5ff050a366ae6376847efcc84e24 to your computer and use it in GitHub Desktop.
Webpack Init File for Laravel/Vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//================================================================================= | |
// WEBPACK MODULES | |
//================================================================================= | |
const ora = require('ora'); | |
const path = require('path'); | |
const chalk = require('chalk'); | |
const rimraf = require('rimraf') | |
const webpack = require('webpack'); | |
const config = require('./webpack.config'); | |
//================================================================================= | |
// WEBPACK OPTIONS | |
//================================================================================= | |
if(process.env.NODE_ENV == 'development-watch'){ | |
process.env.NODE_ENV = 'development'; | |
config.watch = true; | |
} | |
else if(process.env.NODE_ENV == 'production-watch'){ | |
process.env.NODE_ENV = 'production'; | |
config.watch = true; | |
} | |
//================================================================================= | |
// WEBPACK BUILD | |
//================================================================================= | |
var spinner = ora('Building for ' + process.env.NODE_ENV); | |
spinner.start(); | |
rimraf(path.join(__dirname, 'public/assets'), function(err) { | |
if (err) { | |
throw err; | |
} | |
webpack(config, function(err, stats) { | |
spinner.stop() | |
if (err) throw err; | |
process.stdout.write(stats.toString({ | |
colors: true, | |
modules: false, | |
children: false, | |
chunks: false, | |
chunkModules: false | |
}) + '\n\n'); | |
var options = ''; | |
if (config.watch) options = ' - watching for changes'; | |
console.log(chalk.cyan('Build complete' + options + '.\n')) | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment