webpack.config.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const webpack = require('webpack')
  2. const path = require('path')
  3. const autoprefixer = require('autoprefixer')
  4. const extractTextPlugin = require('extract-text-webpack-plugin')
  5. const uglifyJsPlugin = require('uglifyjs-webpack-plugin')
  6. const entryFile = path.resolve(__dirname, 'src/index.js')
  7. const inputPath = path.resolve(__dirname, 'src/')
  8. const outputPath = path.resolve(__dirname, 'static/')
  9. module.exports = {
  10. entry: entryFile,
  11. output: {
  12. path: outputPath,
  13. filename: 'app.js'
  14. },
  15. plugins: [
  16. new webpack.NoEmitOnErrorsPlugin(),
  17. new extractTextPlugin({
  18. filename: 'app.css',
  19. allChunks: true
  20. }),
  21. new uglifyJsPlugin()
  22. ],
  23. module: {
  24. rules: [
  25. {
  26. test: /\.(js|jsx)$/,
  27. exclude: /(node_modules|bower_modules)/,
  28. include: inputPath,
  29. loader: 'babel-loader'
  30. },
  31. {
  32. test: /\.less$/,
  33. use: extractTextPlugin.extract({
  34. fallback: 'style-loader',
  35. use: [
  36. {
  37. loader: 'css-loader',
  38. options: {
  39. minimize: true
  40. }
  41. },
  42. {
  43. loader: 'less-loader'
  44. }
  45. ]
  46. })
  47. },
  48. {
  49. test: /\.(ttf|eot|svg|woff|woff2)(\?.+)?$/,
  50. loader: 'file-loader?name=[hash:12].[ext]'
  51. }
  52. ]
  53. }
  54. }