webpack.config.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. var webpack = require('webpack');
  10. const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
  11. var 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. uglifyOptions: {
  47. ecma: 8,
  48. compress: {
  49. warnings: false
  50. },
  51. }
  52. })
  53. // new webpack.optimize.UglifyJsPlugin({
  54. // compress: {
  55. // warnings: false
  56. // }
  57. // })
  58. ],
  59. watch: true
  60. };