UNPKG

aframe-colorwheel-component

Version:

A-Frame Color Wheel component, designed for A-Frame Material

84 lines (77 loc) 1.91 kB
var path = require('path'); var childProcess = require('child_process'); var webpack = require('webpack'); // Add HMR for development environments only. var entry = ['./index.js']; if (process.env.NODE_ENV === 'dev') { entry = [ 'webpack-dev-server/client?http://localhost:7001', 'webpack/hot/only-dev-server' ].concat(entry); } function getBuildTimestamp () { function pad2 (value) { return ('0' + value).slice(-2); } var date = new Date(); var timestamp = [ pad2(date.getUTCDate()), pad2(date.getUTCMonth()+1), date.getUTCFullYear() ] return timestamp.join('-'); } var commitHash = childProcess.execSync('git rev-parse HEAD').toString(); // Minification. var plugins = [ new webpack.DefinePlugin({ 'process.env':{ 'NODE_ENV': JSON.stringify(process.env.NODE_ENV) }, VERSION: JSON.stringify(require('./package.json').version), BUILD_TIMESTAMP: JSON.stringify(getBuildTimestamp()), COMMIT_HASH: JSON.stringify(commitHash) }), ]; if (process.env.NODE_ENV === 'production') { plugins.push(new webpack.optimize.UglifyJsPlugin({ compress: {warnings: false} })); } // dist/ var filename = 'aframe-colorwheel-component.js'; var outPath = 'dist'; if (process.env.NODE_ENV === 'production') { filename = 'aframe-colorwheel-component.min.js'; } module.exports = { devServer: { port: 7001, watchOptions:{ aggregateTimeout: 300, poll: 1000 } }, disableHostCheck: true, entry: entry, devtool : 'sourcemap', output: { path: path.join(__dirname, outPath), filename: filename, publicPath: '/dist/' }, module: { loaders: [ { test: /\.js?$/, exclude: /(node_modules|bower_components)/, loader: 'babel', query: { plugins: ['transform-class-properties'], presets: ['es2015'] } } ] }, plugins: plugins };