https://github.com/transcranial/keras-js
Raw File
Tip revision: 7713c554f062a77b6897892c2d10209e72576868 authored by Leon Chen on 16 August 2018, 16:45:17 UTC
add deprecation notice
Tip revision: 7713c55
webpack.config.js
const path = require('path')
const webpack = require('webpack')

const config = {
  entry: path.resolve(__dirname, 'src/index'),
  resolve: { extensions: ['.js'] },
  output: { path: path.resolve(__dirname, 'dist'), filename: 'keras.min.js', library: 'KerasJS', libraryTarget: 'umd' },
  module: {
    rules: [{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ }]
  },
  node: {
    fs: 'empty'
  }
}

if (process.env.NODE_ENV === 'production') {
  config.plugins = [
    new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }),
    // scope hoisting
    new webpack.optimize.ModuleConcatenationPlugin(),
    // uglify: unused needs to be set to false or else library will not work properly
    new webpack.optimize.UglifyJsPlugin({
      compress: { warnings: false, unused: false },
      output: { comments: false }
    })
  ]
} else {
  config.devtool = 'eval'
  config.plugins = [new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('development') })]
}

module.exports = config
back to top