Advertisement
Guest User

webpack prod

a guest
Dec 8th, 2016
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. var webpack = require('webpack');
  2. var path = require('path');
  3. var WebpackNotifierPlugin = require('webpack-notifier');
  4. var ExtractTextPlugin = require('extract-text-webpack-plugin');
  5. var HappyPack = require('happypack');
  6.  
  7.  
  8. module.exports = [
  9.  
  10. {
  11. context: __dirname,
  12. entry: ['whatwg-fetch', "./js/main.js"],
  13. stats: {children: false},
  14. output: {
  15. path: path.join(__dirname, "assets"),
  16. publicPath: "/assets/", // relative path for github pages
  17. filename: "main.js", // no hash in main.js because index.html is a static page
  18. libraryTarget: "umd",
  19. pathinfo: true
  20. },
  21. plugins: [
  22.  
  23. new WebpackNotifierPlugin({
  24. alwaysNotify: true,
  25. title: __dirname,
  26. contentImage: path.join(__dirname, 'components/images/favicons/android-chrome-96x96.png')
  27. }),
  28.  
  29. new webpack.optimize.DedupePlugin(),
  30.  
  31. new ExtractTextPlugin("main.css"),
  32.  
  33. new webpack.optimize.UglifyJsPlugin({
  34. minimize: true,
  35. sourceMap: true,
  36. warnings: true,
  37. mangle: true,
  38. compress: {
  39. drop_console: true
  40. }
  41. }),
  42.  
  43. new HappyPack({
  44. loaders: ['babel?presets[]=es2015&presets[]=stage-0&presets[]=react']
  45. }),
  46.  
  47. ],
  48. debug: true,
  49. devtool: "eval",
  50. module: {
  51. loaders: [
  52. {
  53. test: /\.jsx?$/,
  54. exclude: /(node_modules|bower_components)/,
  55. loader: "happypack/loader"
  56. },
  57. {
  58. test: /\.css$/,
  59. exclude: /(node_modules|bower_components)/,
  60. loader: ExtractTextPlugin.extract("style-loader", "css-loader")
  61. },
  62. {
  63. test: /\.(png|jpg|svg|gif|eot|woff|woff2|ttf)$/,
  64. exclude: /(node_modules|bower_components)/,
  65. loader: "url-loader?limit=10000"
  66. },
  67. ]
  68. },
  69. externals: {
  70. //don't bundle the 'react' npm package with our bundle.js
  71. //but get it from a global 'React' variable
  72. //'react': 'React'
  73. 'jQuery': 'jQuery',
  74. 'leaflet': "L",
  75. 'esri-leaflet': 'L.esri',
  76. 'sjcl': 'sjcl',
  77. 'leaflet-freedraw': 'L.FreeDraw'
  78. },
  79. recordsOutputPath: path.join(__dirname, "records.json"),
  80. resolve: {
  81. fallback: path.join(__dirname, "jam"),
  82. extensions: ['', '.js', '.jsx'],
  83. modulesDirectories: ["node_modules"],
  84. root: [path.resolve('./js')]
  85. }
  86. }
  87. ];
  88.  
  89. console.log("PRODUCTION WEBPACK");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement