module.config.js 1.2 KB

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