Nav apraksta

webpack.base.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. var path = require('path')
  2. , fs = require('fs')
  3. , ExtractTextPlugin = require('extract-text-webpack-plugin')
  4. module.exports = {
  5. module: {
  6. //加载器配置
  7. rules: [
  8. {
  9. test: /\.(scss|css)$/,
  10. use: ExtractTextPlugin.extract([
  11. // 'style-loader',
  12. 'css-loader',
  13. 'sass-loader'
  14. ])
  15. }, {
  16. test: /\.(js|jsx)$/,
  17. exclude: [
  18. /node_modules/,
  19. /dist/
  20. ],
  21. use: [
  22. {
  23. loader: 'babel-loader',
  24. options: {
  25. ...JSON.parse(fs.readFileSync(path.resolve(__dirname, '../.babelrc'))),
  26. },
  27. },
  28. 'eslint-loader'
  29. ]
  30. }, {
  31. test: /\.(png|svg)$/,
  32. use: [
  33. {
  34. loader: 'url-loader',
  35. options: {
  36. limit: 8192,
  37. name: '[name]_[hash:6].[ext]'
  38. }
  39. }
  40. ]
  41. }, {
  42. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  43. use: [
  44. {
  45. loader: 'url-loader',
  46. options: {
  47. limit: 20000,
  48. name: '[name].[ext]',
  49. publicPath: './'
  50. }
  51. }
  52. ]
  53. }
  54. ]
  55. },
  56. resolve: {
  57. modules: [path.resolve(__dirname, '../src'), 'node_modules'],
  58. alias: {
  59. 'react': path.join(__dirname, '../node_modules', 'react'),
  60. 'scssinc': path.join(__dirname, '../src/assets/scss/_inc.scss')
  61. },
  62. extensions: ['.js', '.jsx']
  63. }
  64. }