Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. const path = require('path');
  2. const htmlWebpackPlugin = require('html-webpack-plugin');
  3. const webpack = require('webpack');
  4. const miniCssExtractPlugin = require('mini-css-extract-plugin');
  5. const modernizrWebpackPlugin = require('modernizr-webpack-plugin');
  6. const htmlWebpackIncludeAssetsPlugin = require('html-webpack-include-assets-plugin');
  7. const configMorenizr = require('./modernizr.config.js');
  8. const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
  9.  
  10. module.exports = {
  11. entry: {
  12. index: ['webpack-hot-middleware/client?reload=true','./src/build/js/index.bundle'],
  13. contato: ['webpack-hot-middleware/client?reload=true', './src/build/js/contato.bundle'],
  14. },
  15. mode:"development",
  16. output: {
  17. filename: '[name]-bundle.js',
  18. path: path.resolve(__dirname, '../dist'),
  19. publicPath: '/'
  20. },
  21. optimization:{
  22. splitChunks: {
  23. chunks: 'all',
  24. name: true,
  25. cacheGroups: {
  26. commons: {
  27. chunks: 'initial',
  28. minChunks: 5,
  29. maxInitialRequests: 5,
  30. minSize: 0,
  31. name: 'commons'
  32. },
  33. vendors: {
  34. test: /[\/]node_modules[\/]/,
  35. chunks: "initial",
  36. priority: 10,
  37. enforce: true,
  38. name: 'vendors'
  39. }
  40. }
  41. }
  42. },
  43. devtool: 'inline-source-map',
  44. devServer: {
  45. contentBase: 'dist',
  46. overlay: true,
  47. hot: true,
  48. stats: {
  49. colors: true
  50. }
  51. },
  52. module: {
  53. rules: [
  54. {
  55. test: /.js$/,
  56. exclude: /node_modules/,
  57. use: [
  58. {
  59. loader: 'babel-loader'
  60. }
  61. ]
  62. },
  63. {
  64. test: /.(scss|sass)$/,
  65. use: [
  66. {
  67. loader: 'style-loader'
  68. },
  69. {
  70. loader: 'css-loader',
  71. options: {
  72. importLoaders: 2,
  73. sourceMap: true
  74. }
  75. },
  76. {
  77. loader: 'postcss-loader',
  78. },
  79. {
  80. loader: 'sass-loader'
  81.  
  82. }
  83. ]
  84. },
  85. {
  86. test: /.pug$/,
  87. use: [
  88. {
  89. loader: 'pug-loader'
  90. }
  91. ]
  92. },
  93. {
  94. test: /.(jpg|png|svg|jpeg|gif)$/,
  95. use: [
  96. {
  97. loader: 'file-loader',
  98. options: {
  99. name: 'images/[name].[ext]'
  100. }
  101. }
  102. ]
  103. }
  104. ]
  105. },
  106. plugins: [
  107. new webpack.HotModuleReplacementPlugin(),
  108. new miniCssExtractPlugin(),
  109. new htmlWebpackPlugin({
  110. filename: 'index.html',
  111. template: './src/build/pug/index.pug',
  112. chunks: ['index', 'vendors']
  113. }),
  114. new htmlWebpackPlugin({
  115. filename: 'contact.html',
  116. template: './src/build/pug/contact.pug',
  117. chunks: ['contato', 'vendors']
  118. }),
  119. new htmlWebpackIncludeAssetsPlugin({
  120. files: ['index.html'],
  121. assets: [],
  122. append: true
  123. }),
  124. new htmlWebpackIncludeAssetsPlugin({
  125. files: ['contact.html'],
  126. assets: [],
  127. append: true
  128. }),
  129. new modernizrWebpackPlugin(configMorenizr),
  130. new htmlWebpackIncludeAssetsPlugin({
  131. assets: ['modernizr-bundle.js'],
  132. append: false
  133. }),
  134. // new BundleAnalyzerPlugin({
  135. // generateStatsFile: true
  136. // })
  137. ]
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement