No Description

webpack.config.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. var fs = require('fs');
  2. var path = require('path');
  3. var webpack = require('webpack');
  4. var configs = module.exports = [
  5. {
  6. name: 'Browser',
  7. entry: {
  8. app: './src/js/browser.jsx',
  9. vendors: [ 'react', 'react-router' ]
  10. },
  11. output: {
  12. path: __dirname + '/public/assets/',
  13. publicPath: '/assets/',
  14. filename: 'bundle.js'
  15. },
  16. plugins: [
  17. new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js')
  18. ],
  19. module: {
  20. loaders: [
  21. { test: /\.json$/, loader: 'json-loader' },
  22. { test: /\.jsx?$/, loader: 'babel-loader?optional[]=runtime&stage=0', exclude: /(node_modules|bower_components)/ },
  23. { test: /\.less$/, loader: 'style!css!less' },
  24. { test: /\.png$/, loader: "url-loader?prefix=img/&limit=5000" },
  25. { test: /\.jpg$/, loader: "url-loader?prefix=img/&limit=5000" },
  26. { test: /\.gif$/, loader: "url-loader?prefix=img/&limit=5000" },
  27. { test: /\.woff$/, loader: "url-loader?prefix=font/&limit=5000" }
  28. ]
  29. },
  30. resolve: {
  31. alias: {
  32. Source: __dirname + '/src',
  33. Extension: __dirname + '/src/extensions'
  34. }
  35. }
  36. },
  37. {
  38. name: 'Server-side rendering',
  39. entry: {
  40. app: './src/js/server.js'
  41. },
  42. target: 'node',
  43. output: {
  44. libraryTarget: 'commonjs2',
  45. path: __dirname + '/build',
  46. publicPath: '/assets/',
  47. filename: 'server.js'
  48. },
  49. node: {
  50. __filename: true
  51. },
  52. externals: fs.readdirSync('./node_modules').map(function(module) {
  53. return module
  54. }),
  55. plugins: [
  56. new webpack.DefinePlugin({ 'global.GENTLY': false })
  57. ],
  58. module: {
  59. loaders: [
  60. { test: /\.json$/, loader: 'json-loader' },
  61. { test: /\.jsx?$/, loader: 'babel-loader?optional[]=runtime&stage=0', exclude: /(node_modules|bower_components)/ },
  62. { test: /\.less$/, loader: 'style!css!less' },
  63. { test: /\.png$/, loader: "file-loader" },
  64. { test: /\.jpg$/, loader: "file-loader" },
  65. { test: /\.gif$/, loader: "file-loader" },
  66. { test: /\.woff$/, loader: "file-loader" }
  67. ]
  68. },
  69. resolve: {
  70. alias: {
  71. Source: __dirname + '/src',
  72. Extension: __dirname + '/src/extensions'
  73. }
  74. }
  75. }
  76. ];