webpack.config.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. // regular css files
  24. test: /\.css$/,
  25. use: ExtractTextPlugin.extract({ use: 'css-loader?importLoaders=1', }),
  26. },
  27. {
  28. // sass / scss loader for webpack
  29. test: /\.(sass|scss)$/,
  30. use: ExtractTextPlugin.extract(['css-loader', 'sass-loader'])
  31. },
  32. {
  33. // fonts
  34. test: /\.(eot|svg|ttf|woff|woff2)$/,
  35. use: "file-loader?name=fonts/[name].[ext]"
  36. },
  37. ]
  38. },
  39. plugins: [
  40. new ExtractTextPlugin({
  41. // define where to save the file
  42. filename: '[name].css', allChunks: true,
  43. }),
  44. new UglifyJsPlugin({
  45. sourceMap: true,
  46. parallel:4,
  47. uglifyOptions: {
  48. ecma: 8,
  49. // disable most of compress to gain in compilation speed
  50. // https://slack.engineering/keep-webpack-fast-a-field-guide-for-better-build-performance-f56a5995e8f1
  51. compress: {
  52. arrows: false,
  53. booleans: false,
  54. // cascade: false,
  55. collapse_vars: false,
  56. comparisons: false,
  57. computed_props: false,
  58. hoist_funs: false,
  59. hoist_props: false,
  60. hoist_vars: false,
  61. if_return: false,
  62. inline: false,
  63. join_vars: false,
  64. keep_infinity: true,
  65. loops: false,
  66. negate_iife: false,
  67. properties: false,
  68. reduce_funcs: false,
  69. reduce_vars: false,
  70. sequences: false,
  71. side_effects: false,
  72. switches: false,
  73. top_retain: false,
  74. toplevel: false,
  75. typeofs: false,
  76. unused: false,
  77. conditionals: false,
  78. dead_code: true,
  79. evaluate: false,
  80. warnings: false
  81. },
  82. }
  83. })
  84. ],
  85. watch: true
  86. };