webpack.config.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. const {resolve} = require('path');
  2. const webpack = require('webpack');
  3. module.exports = {
  4. context: resolve(__dirname, 'app'),
  5. entry: [
  6. 'webpack-dev-server/client?http://localhost:8080',
  7. // bundle the client for webpack-dev-server
  8. // and connect to the provided endpoint
  9. './app.js'
  10. // the entry point of our app
  11. ],
  12. output: {
  13. filename: 'bundle.js',
  14. // the output bundle
  15. path: resolve(__dirname, 'public'),
  16. },
  17. devtool: 'inline-source-map',
  18. devServer: {
  19. contentBase: resolve(__dirname, 'public'),
  20. // match the output path
  21. publicPath: '/',
  22. // match the output `publicPath`
  23. historyApiFallback: true
  24. },
  25. resolve: {
  26. extensions: [
  27. '.js', '.jsx', '.css', '.less'
  28. ],
  29. modules: ['./app', './node_modules']
  30. },
  31. module: {
  32. rules: [
  33. {
  34. test: /\.(js|jsx)?$/,
  35. use: ['babel-loader'],
  36. exclude: /node_modules/
  37. }, {
  38. test: /\.(less|css)$/,
  39. use: ['style-loader', 'css-loader?modules', 'less-loader']
  40. }, {
  41. test: /\.(jpg|png|gif)$/,
  42. use: 'file-loader'
  43. }, {
  44. test: /\.(woff|woff2|eot|ttf|svg)$/,
  45. use: {
  46. loader: 'url-loader',
  47. options: {
  48. limit: 100000
  49. }
  50. }
  51. }
  52. ]
  53. }
  54. }