Guest User

Untitled

a guest
Feb 23rd, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. /* global __dirname, require, module*/
  2.  
  3. const webpack = require('webpack');
  4. const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
  5. const path = require('path');
  6. const env = require('yargs').argv.env; // use --env with webpack 2
  7. let libraryName = 'game-lib';
  8.  
  9. let plugins = [], outputFile;
  10.  
  11. if (env === 'build') {
  12. plugins.push(new UglifyJsPlugin({ minimize: true }));
  13. outputFile = libraryName + '.min.js';
  14. } else {
  15. outputFile = libraryName + '.js';
  16. }
  17. const config = {
  18. entry: ['./app/index.js'],
  19. output: {
  20. path: path.resolve(__dirname, 'build'),
  21. filename: outputFile
  22. },
  23. module: {
  24. loaders: [
  25. {
  26. loader:'babel-loader',
  27. test: /\.js$/,
  28. exclude: /node_modules/
  29. }
  30. ]
  31. },
  32. resolve: {
  33. extensions: ['.js']
  34. },
  35. devServer:{
  36. port: 3000,
  37. contentBase: __dirname + '/build',
  38. inline: true
  39. },
  40. plugins: plugins
  41. }
  42. module.exports = config;
Add Comment
Please, Sign In to add comment