Guest User

Untitled

a guest
Oct 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. const autoprefixer = require("autoprefixer");
  2. const eslintFormatter = require("react-dev-utils/eslintFormatter");
  3. const flexbugsFixes = require("postcss-flexbugs-fixes");
  4. const HtmlWebpackPlugin = require("html-webpack-plugin");
  5. const webpack = require("webpack");
  6.  
  7. // Utils
  8. const envs = require("./env");
  9. const paths = require("./paths");
  10.  
  11. // Plugins
  12. const definePlugin = new webpack.DefinePlugin(envs);
  13. const htmlWebpackPlugin = new HtmlWebpackPlugin({
  14. inject: true,
  15. template: paths.appHtml
  16. });
  17. const hotModuleReplacementPlugin = new webpack.HotModuleReplacementPlugin();
  18.  
  19. module.exports = {
  20. mode: "development",
  21. devtool: "cheap-module-eval-source-map",
  22. entry: paths.appIndexJs,
  23. output: {
  24. path: paths.appPublic,
  25. publicPath: "/",
  26. filename: "[name].js",
  27. chunkFilename: "[name].chunk.js"
  28. },
  29. resolve: {
  30. extensions: [".js", ".jsx"]
  31. },
  32. module: {
  33. rules: [
  34. {
  35. enforce: "pre",
  36. test: /\.(js|jsx)$/,
  37. include: paths.appSrc,
  38. use: [
  39. {
  40. loader: "eslint-loader",
  41. options: {
  42. formatter: eslintFormatter,
  43. eslintPath: "eslint"
  44. }
  45. }
  46. ]
  47. },
  48. {
  49. test: /\.(js|jsx)$/,
  50. include: paths.appSrc,
  51. use: ["babel-loader"]
  52. },
  53. {
  54. test: /\.css$/,
  55. include: paths.appSrc,
  56. use: [
  57. { loader: "style-loader" },
  58. {
  59. loader: "css-loader"
  60. },
  61. {
  62. loader: "postcss-loader",
  63. options: {
  64. ident: "postcss",
  65. plugins: () => [
  66. flexbugsFixes,
  67. autoprefixer({
  68. browsers: ["> 1%", "last 2 versions"]
  69. })
  70. ]
  71. }
  72. }
  73. ]
  74. },
  75. {
  76. test: /\.(eot|svg|otf|ttf|woff|woff2)$/,
  77. use: "file-loader"
  78. },
  79. {
  80. test: /\.(jpg|png|gif)$/,
  81. use: [
  82. "file-loader",
  83. {
  84. loader: "image-webpack-loader",
  85. options: {
  86. name: "[path][name]-[hash:8].[ext]",
  87. query: {
  88. gifsicle: {
  89. interlaced: true
  90. },
  91. mozjpeg: {
  92. progressive: true
  93. },
  94. optipng: {
  95. optimizationLevel: 7
  96. },
  97. pngquant: {
  98. quality: "65-90",
  99. speed: 4
  100. }
  101. }
  102. }
  103. }
  104. ]
  105. }
  106. ]
  107. },
  108. plugins: [definePlugin, htmlWebpackPlugin, hotModuleReplacementPlugin],
  109. devServer: {
  110. contentBase: paths.appPublic,
  111. historyApiFallback: true,
  112. hot: true,
  113. port: 3001,
  114. watchContentBase: true
  115. }
  116. };
Add Comment
Please, Sign In to add comment