const path = require('path');
const config = require('./package.json');

const webpack = require('webpack');
require('dotenv').config();

const PROD = process.env.NODE_ENV === 'production';

// let plugins = [];

// PROD ? [
//   plugins.push(new webpack.optimize.UglifyJsPlugin({
//     compress: { warnings: false }
//   }))
// ] : '';

module.exports = {
  entry: path.resolve(__dirname, config.main),
  output: {
    library: process.env.NAME,
    libraryTarget: process.env.TARGET,
    path: path.resolve(__dirname, "dist"),
    filename: (PROD) ? 'autoscroll.min.js' : 'autoscroll.js'
  },
  // devtool: 'source-map',
  module: {
    rules: [
      {
        test: /\.js?$/,
        exclude: /(node_modules|bower_components)/,
        use: ['babel-loader']
      }
    ],
  }
  // plugins: plugins
};

const path = require('path')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const config = require('./package.json')

const webpack = require('webpack')

// Config object
const library = {
  name: 'VueAutoscroll',
  target: 'umd'
}

const DEV = process.env.NODE_ENV === 'development';

let webpackConfig = {
  entry: path.resolve(__dirname, config.main),
  watch: DEV,
  output: {
    library: library.name,
    libraryTarget: library.target,
    path: path.resolve(__dirname, "dist"),
    filename: (DEV) ? 'autoscroll.js' : 'autoscroll.min.js'
  },
  // devtool: 'source-map',
  module: {
    rules: [
      {
        test: /\.js?$/,
        exclude: /(node_modules|bower_components)/,
        use: ['babel-loader']
      }
    ],
  },
  plugins: []
}

if(!DEV) {
  webpackConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({compress: { warnings: false }}))
}

module.exports = webpackConfig

Remove dotenv execution, create library object that contain library infos. watch if DEV MODE and UGLIFY if PROD MODE
Remove dotenv execution, create library object that contain library infos. watch if DEV MODE and UGLIFY if PROD MODE
