webpack.config.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. var Path = require('path');
  2. var LiveReloadPlugin = require('webpack-livereload-plugin')
  3. var ExtractTextPlugin = require('extract-text-webpack-plugin')
  4. var prod = process.env.NODE_ENV === 'production'
  5. module.exports = {
  6. entry: Path.resolve('src/index.js'),
  7. output: {
  8. path: Path.resolve('static/src'),
  9. filename: 'main.js'
  10. },
  11. resolve: {
  12. extensions: ['.js', '.vue', '.json'],
  13. alias: {
  14. 'vue$': 'vue/dist/vue.esm.js',
  15. '@': Path.resolve('src'),
  16. '@@': Path.resolve('src/components')
  17. }
  18. },
  19. plugins: [
  20. new LiveReloadPlugin({
  21. hostname: "192.168.88.130",
  22. port: 8075
  23. }),
  24. new ExtractTextPlugin('main.css')
  25. ],
  26. module: {
  27. rules: [
  28. {
  29. test: /\.vue$/,
  30. loader: 'vue-loader',
  31. options :{
  32. extractCSS: prod
  33. }
  34. },
  35. {
  36. test: /\.js$/,
  37. exclude: /node_modules/,
  38. loader: 'babel-loader',
  39. include: Path.resolve('src')
  40. },
  41. {
  42. test: /\.css$/,
  43. loader: ['style-loader', 'css-loader']
  44. },
  45. {
  46. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  47. loader: 'url-loader',
  48. options: {
  49. limit: 10000,
  50. name: Path.posix.join('static', 'img/[name].[hash:7].[ext]')
  51. }
  52. }
  53. ]
  54. }
  55. }