webpack.config.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. var path = require('path'),
  2. webpack = require('webpack'),
  3. CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin"),
  4. ExtractTextPlugin = require("extract-text-webpack-plugin");
  5. var source_dir = __dirname + '/src/main/resources/static/js',
  6. node_dir = __dirname + '/node_modules';
  7. var config = {
  8. entry: {
  9. app: [source_dir + '/app.render'],
  10. vendors: [source_dir + '/vendors']
  11. },
  12. resolve: {
  13. extensions: ['', '.js', '.jsx', '.css']
  14. },
  15. devtool: 'source-map',
  16. cache: true,
  17. debug: true,
  18. output: {
  19. path: './target/classes/static/js',
  20. filename: '[name].bundle.js'
  21. },
  22. plugins: [
  23. new ExtractTextPlugin("../css/[name].css"),
  24. new CommonsChunkPlugin("vendors", null, true),
  25. ],
  26. module: {
  27. loaders: [
  28. {
  29. test: /\.jsx?$/,
  30. exclude: /(node_modules)/,
  31. loader: 'babel',
  32. query: {
  33. cacheDirectory: true,
  34. presets: ['es2015', 'react']
  35. }
  36. },
  37. {
  38. test: /\.css$/,
  39. loader: ExtractTextPlugin.extract("style-loader", "css-loader!postcss-loader")
  40. },
  41. {
  42. test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
  43. loader: "file?name=../css/[name].[ext]"
  44. },
  45. {
  46. test: /\.(woff|woff2)$/,
  47. loader:"url?prefix=font/&limit=5000&name=../css/[name].[ext]"
  48. },
  49. {
  50. test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
  51. loader: "url?limit=10000&mimetype=application/octet-stream&&name=../css/[name].[ext]"
  52. },
  53. {
  54. test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
  55. loader: "url?limit=10000&mimetype=image/svg+xml&&name=../css/[name].[ext]"
  56. }
  57. ]
  58. },
  59. postcss: function () {
  60. return [];
  61. }
  62. };
  63. module.exports = config;