xExekut3x

webpack

Dec 16th, 2016
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. const fs = require('fs'),
  2. path = require('path'),
  3. webpack = require('webpack'),
  4. HtmlWebpackPlugin = require('html-webpack-plugin'),
  5. WebpackCleanupPlugin = require('webpack-cleanup-plugin'),
  6. BUILD_DIR = path.resolve(__dirname, 'build'),
  7. APP_DIR = path.resolve(__dirname, 'app'),
  8. ENV = process.env.NODE_ENV || 'development',
  9. PROD = ENV === 'production'
  10.  
  11. module.exports = {
  12. devtool: 'source-map',
  13. entry: path.resolve(APP_DIR, 'index'),
  14. output: {
  15. path: BUILD_DIR,
  16. filename: 'bundle.js'
  17. },
  18. resolve: {
  19. modules: [
  20. 'node_modules',
  21. APP_DIR
  22. ],
  23. extensions: ['', '.js', '.jsx']
  24. },
  25. module: {
  26. rules: [
  27. {
  28. test: /\.jsx?$/,
  29. loader: 'babel-loader',
  30. exlude: /node_modules/,
  31. loader: 'babel-loader'
  32. }
  33. ]
  34. },
  35. plugins: [
  36. new HtmlWebpackPlugin({
  37. template: path.resolve(APP_DIR, 'index.tpl.html'),
  38. minify: {
  39. collapseWhitespace: true
  40. }
  41. }),
  42. new webpack.DefinePlugin({
  43. 'process.env': {
  44. 'NODE_ENV': JSON.stringify(ENV)
  45. }
  46. })
  47. ]
  48. }
Advertisement
Add Comment
Please, Sign In to add comment