webpack.config.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * @Author: Bachir Soussi Chiadmi <bach>
  3. * @Date: 11-04-2017
  4. * @Email: bachir@figureslibres.io
  5. * @Last modified by: bach
  6. * @Last modified time: 16-04-2017
  7. * @License: GPL-V3
  8. */
  9. const webpack = require('webpack');
  10. const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
  11. const ExtractTextPlugin = require('extract-text-webpack-plugin');
  12. module.exports = {
  13. entry: ["./assets/main.js", "./assets/main.scss"],
  14. output: {
  15. path: __dirname + "/assets/dist/",
  16. filename: "main.js"
  17. },
  18. devtool: 'source-map',
  19. module: {
  20. rules: [
  21. /* your other rules for JavaScript transpiling go in here */
  22. {
  23. test: /\.js$/,
  24. exclude: /(node_modules|bower_components)/,
  25. use: {
  26. loader: 'babel-loader',
  27. options: {
  28. presets: ['es2015'],
  29. // plugins: [require('@babel/plugin-proposal-object-rest-spread')]
  30. }
  31. }
  32. },
  33. {
  34. // regular css files
  35. test: /\.css$/,
  36. use: ExtractTextPlugin.extract({ use: 'css-loader?importLoaders=1', }),
  37. },
  38. {
  39. // sass / scss loader for webpack
  40. test: /\.(sass|scss)$/,
  41. use: ExtractTextPlugin.extract(['css-loader', 'sass-loader'])
  42. },
  43. {
  44. // fonts
  45. test: /\.(eot|svg|ttf|woff|woff2)$/,
  46. use: "file-loader?name=fonts/[name].[ext]"
  47. }
  48. ]
  49. },
  50. plugins: [
  51. new ExtractTextPlugin({
  52. // define where to save the file
  53. filename: '[name].css', allChunks: true,
  54. }),
  55. new UglifyJsPlugin({
  56. sourceMap: true,
  57. parallel:4,
  58. uglifyOptions: {
  59. ecma: 8,
  60. // disable most of compress to gain in compilation speed
  61. // https://slack.engineering/keep-webpack-fast-a-field-guide-for-better-build-performance-f56a5995e8f1
  62. compress: {
  63. arrows: false,
  64. booleans: false,
  65. // cascade: false,
  66. collapse_vars: false,
  67. comparisons: false,
  68. computed_props: false,
  69. hoist_funs: false,
  70. hoist_props: false,
  71. hoist_vars: false,
  72. if_return: false,
  73. inline: false,
  74. join_vars: false,
  75. keep_infinity: true,
  76. loops: false,
  77. negate_iife: false,
  78. properties: false,
  79. reduce_funcs: false,
  80. reduce_vars: false,
  81. sequences: false,
  82. side_effects: false,
  83. switches: false,
  84. top_retain: false,
  85. toplevel: false,
  86. typeofs: false,
  87. unused: false,
  88. conditionals: false,
  89. dead_code: true,
  90. evaluate: false,
  91. warnings: false
  92. },
  93. }
  94. })
  95. ],
  96. watch: true
  97. };