webpack.config.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. const path = require('path');
  2. const HtmlWebpackPlugin = require('html-webpack-plugin');
  3. const CleanWebpackPlugin = require("clean-webpack-plugin");
  4. const ExtractTextPlugin = require('extract-text-webpack-plugin');
  5. const autoprefixer = require('autoprefixer');
  6. const outputDirectory = "build";
  7. module.exports = {
  8. entry: './src/index.js',
  9. output: {
  10. library: 'Branding',
  11. path: path.resolve(__dirname, outputDirectory),
  12. filename: 'index.js',
  13. },
  14. devtool: 'source-map',
  15. module: {
  16. rules: [
  17. {
  18. test: /\.jsx?$/,
  19. exclude: /node_modules/,
  20. use: [
  21. {
  22. loader: 'babel-loader',
  23. options: {
  24. presets: ['react']
  25. }
  26. }
  27. ]
  28. },
  29. {
  30. test: /\.(sa|sc|c)ss$/,
  31. use: ExtractTextPlugin.extract({
  32. fallback: 'style-loader',
  33. use: [
  34. {
  35. loader: "css-loader",
  36. options: {
  37. sourceMap: true
  38. }
  39. },
  40. {
  41. loader: 'postcss-loader',
  42. options: {
  43. plugins: [
  44. autoprefixer({
  45. Browserslist: [
  46. '>1%',
  47. 'last 4 versions',
  48. 'Firefox ESR',
  49. 'not ie < 9', // React doesn't support IE8 anyway
  50. ]
  51. })
  52. ],
  53. sourceMap: true
  54. }
  55. },
  56. {
  57. loader: "sass-loader",
  58. options: {
  59. sourceMap: true
  60. }
  61. }
  62. ]
  63. })
  64. },
  65. {
  66. test: /\.(cur|ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
  67. use: {
  68. loader: 'file-loader',
  69. query: {
  70. name: '[name].[hash:8].[ext]',
  71. outputPath: './assets/media/',
  72. publicPath: '/'
  73. }
  74. }
  75. },
  76. {
  77. test: /\.(mp4|webm|wav|mp3|m4a|aac|oga)(\?.*)?$/,
  78. use: {
  79. loader: 'url-loader',
  80. query: {
  81. limit: 10000,
  82. name: '[name].[hash:8].[ext]',
  83. outputPath: './assets/media/',
  84. publicPath: '/'
  85. }
  86. }
  87. }
  88. ]
  89. },
  90. plugins: [
  91. new CleanWebpackPlugin([outputDirectory]),
  92. new ExtractTextPlugin({
  93. filename: 'assets/css/[name].[contenthash:8].css'
  94. }),
  95. ]
  96. };