failing.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. const webpack = require("webpack");
  2. const nodeEnvironment = process.env.NODE_ENV;
  3. const _ = require("lodash");
  4. const config = {
  5. entry: {
  6. lib: "./app/index.js",
  7. email: "./app/email.js"
  8. },
  9. plugins: [
  10. new webpack.DefinePlugin({
  11. INCLUDE_ALL_MODULES: function includeAllModulesGlobalFn(modulesArray, application) {
  12. modulesArray.forEach(function executeModuleIncludesFn(moduleFn) {
  13. moduleFn(application);
  14. });
  15. },
  16. ENVIRONMENT: JSON.stringify(nodeEnvironment)
  17. })
  18. ],
  19. output: {
  20. path: __dirname + "/app",
  21. filename: "bundle.js"
  22. },
  23. resolve: {
  24. root: __dirname + "/app"
  25. },
  26. module: {
  27. // preLoaders: [
  28. // { test: /\.js?$/, loader: 'eslint', exclude: /node_modules/ }
  29. // ],
  30. loaders: [
  31. { test: /\.js$/, exclude: /(node_modules)/, loader: "babel" },
  32. { test: /\.html/, exclude: [/(node_modules)/, /src\/index\.html/], loader: "html-loader" },
  33. { test: /\.s?css$/, loader: "style!css!sass" },
  34. { test: /\.(png|jpg)$/, loader: "url-loader?mimetype=image/png" }
  35. ]
  36. },
  37. // extra configuration options.
  38. // eslint: {
  39. // configFile: '.eslintrc.js'
  40. // }
  41. };
  42. switch (nodeEnvironment) {
  43. case "production":
  44. config.plugins.push(new webpack.optimize.UglifyJsPlugin());
  45. case "preproduction":
  46. config.output.path = __dirname + "/dist";
  47. config.plugins.push(new webpack.optimize.DedupePlugin());
  48. config.plugins.push(new webpack.optimize.OccurenceOrderPlugin());
  49. config.output.filename = "[name].js";
  50. config.entry = {
  51. lib: ["./app/index.js", "angular", "lodash"],
  52. email: ["./app/email.js", "angular"]
  53. };
  54. config.devtool = "source-map";
  55. config.output.libraryTarget = "commonjs2";
  56. break;
  57. case "test":
  58. config.entry = "./index.js";
  59. break;
  60. case "development":
  61. config.entry = {
  62. lib: ["./app/index.js", "webpack/hot/dev-server"],
  63. email: ["./app/email.js", "webpack/hot/dev-server"]
  64. };
  65. config.output.filename = "[name].js";
  66. config.devtool = "source-map";
  67. break;
  68. default:
  69. console.warn("Unknown or Undefined Node Environment. Please refer to package.json for available build commands.");
  70. }
  71. module.exports = config;