Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. const path = require('path');
  2. const webpack = require('webpack');
  3. const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
  4. const HtmlWebpackPlugin = require('html-webpack-plugin');
  5. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  6. const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
  7.  
  8. // const isProduction = process.env.NODE_ENV === 'production';
  9.  
  10. module.exports = {
  11. target: 'web',
  12.  
  13. entry: {
  14. main: path.resolve(__dirname, 'src', 'index.jsx'),
  15. },
  16.  
  17. output: {
  18. path: path.resolve(__dirname, 'dist'),
  19. filename: '[name].[chunkhash].js',
  20. publicPath: '/',
  21. },
  22.  
  23. module: {
  24. rules: [
  25. {
  26. test: /\.jsx?$/,
  27. exclude: /node_modules(?!\/myuimodule)/,
  28. use: ['babel-loader'],
  29. },
  30. {
  31. test: /\.s?[ac]ss$/,
  32. use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader'],
  33. },
  34. {
  35. test: /\.(png|svg|jpg|gif)$/,
  36. use: ['file-loader'],
  37. },
  38. {
  39. test: /\.(woff|woff2|eot|ttf|otf)$/,
  40. use: ['file-loader'],
  41. },
  42. ],
  43. },
  44.  
  45. plugins: [
  46. new webpack.DefinePlugin({
  47. 'process.env': {
  48. NODE_ENV: JSON.stringify(process.env.NODE_ENV),
  49. },
  50. }),
  51. new HtmlWebpackPlugin({
  52. inject: false,
  53. template: path.join('src', 'index.html'),
  54. title: 'Title',
  55. }),
  56. new MiniCssExtractPlugin({
  57. filename: '[name].[contenthash].css',
  58. chunkFilename: '[name].[contenthash].chunk.css',
  59. }),
  60. ],
  61.  
  62. resolve: {
  63. extensions: ['.js', '.jsx', '.css', '.scss'],
  64. },
  65.  
  66. devServer: {
  67. stats: 'minimal',
  68. historyApiFallback: true,
  69. contentBase: path.resolve(__dirname, 'dist'),
  70. proxy: {
  71. '/api': 'http://localhost:5000',
  72. },
  73. },
  74.  
  75. optimization: {
  76. occurrenceOrder: true,
  77. runtimeChunk: true,
  78. splitChunks: {
  79. cacheGroups: {
  80. vendors: {
  81. chunks: 'all',
  82. name: 'vendor',
  83. test: 'vendor',
  84. enforce: true,
  85. },
  86. },
  87. },
  88. minimizer: [new UglifyJsPlugin({}), new OptimizeCSSAssetsPlugin({})],
  89. },
  90. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement