From 623e05debbfd8eb9a2a010e60c5ab137a3f8b4ff Mon Sep 17 00:00:00 2001 From: Leon Chen Date: Sun, 21 Aug 2016 21:36:07 -0400 Subject: [PATCH] UMD webpack build setup --- webpack.dev.config.js | 33 +++++++++++++++++++++++++++++++++ webpack.prod.config.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 webpack.dev.config.js create mode 100644 webpack.prod.config.js diff --git a/webpack.dev.config.js b/webpack.dev.config.js new file mode 100644 index 0000000..d213cd4 --- /dev/null +++ b/webpack.dev.config.js @@ -0,0 +1,33 @@ +const webpack = require('webpack') + +module.exports = { + devtool: 'cheap-module-eval-source-map', + module: { + loaders: [ + { + test: /\.js$/, + loaders: ['babel-loader'], + exclude: /node_modules/ + } + ] + }, + output: { + library: 'KerasJS', + libraryTarget: 'umd' + }, + resolve: { + extensions: ['', '.js'] + }, + plugins: [ + new webpack.optimize.OccurenceOrderPlugin(), + new webpack.DefinePlugin({ + 'process.env.NODE_ENV': JSON.stringify('production') + }), + new webpack.optimize.UglifyJsPlugin({ + compressor: { + screw_ie8: true, + warnings: false + } + }) + ] +} diff --git a/webpack.prod.config.js b/webpack.prod.config.js new file mode 100644 index 0000000..d849723 --- /dev/null +++ b/webpack.prod.config.js @@ -0,0 +1,34 @@ +const webpack = require('webpack') + +module.exports = { + module: { + loaders: [ + { + test: /\.js$/, + loaders: ['babel-loader'], + exclude: /node_modules/ + } + ] + }, + output: { + library: 'KerasJS', + libraryTarget: 'umd' + }, + resolve: { + extensions: ['', '.js'] + }, + plugins: [ + new webpack.DefinePlugin({ + 'process.env': { + NODE_ENV: JSON.stringify('production') + } + }), + new webpack.optimize.DedupePlugin(), + new webpack.optimize.OccurenceOrderPlugin(), + new webpack.optimize.UglifyJsPlugin({ + compress: { + warnings: false + } + }) + ] +}