module.config.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const ExtractTextPlugin = require("extract-text-webpack-plugin");
  2. module.exports = function (theme) {
  3. return {
  4. rules: [{
  5. test: /\.jsx?$/,
  6. exclude: /node_modules/,
  7. use: {
  8. loader: 'babel-loader',
  9. options: {
  10. "presets": ["es2015", "react"],
  11. "plugins": [
  12. ["antd", {
  13. "style": true
  14. }]
  15. ]
  16. }
  17. }
  18. },
  19. {
  20. test: /\.less$/,
  21. use: ExtractTextPlugin.extract({
  22. fallback: 'style-loader',
  23. use: [{
  24. loader: 'css-loader',
  25. options: {
  26. importLoaders: 1
  27. }
  28. }, {
  29. loader: 'less-loader',
  30. options: {
  31. modifyVars: theme
  32. }
  33. }]
  34. })
  35. }, {
  36. test: /\.(png|jpg)$/,
  37. use: [{
  38. loader: 'url-loader',
  39. options: {
  40. limit: 8192,
  41. name: '[path][name].[ext]'
  42. }
  43. }]
  44. }, {
  45. test: /\.(woff|svg|eot|ttf)$/,
  46. use: [{
  47. loader: 'url-loader',
  48. options: {
  49. limit: 1,
  50. name: '[path][name].[ext]'
  51. }
  52. }]
  53. }
  54. ]
  55. };
  56. }