webpack.config.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. }
  17. },
  18. plugins: [
  19. new LiveReloadPlugin({
  20. hostname: "192.168.88.130",
  21. port: 8071
  22. }),
  23. new ExtractTextPlugin('main.css')
  24. ],
  25. module: {
  26. rules: [
  27. {
  28. test: /\.vue$/,
  29. loader: 'vue-loader',
  30. options :{
  31. extractCSS: prod
  32. }
  33. },
  34. {
  35. test: /\.js$/,
  36. exclude: /node_modules/,
  37. loader: 'babel-loader',
  38. include: Path.resolve('src')
  39. },
  40. {
  41. test: /\.css$/,
  42. loader: ['style-loader', 'css-loader']
  43. },
  44. {
  45. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  46. loader: 'url-loader',
  47. options: {
  48. limit: 10000,
  49. name: Path.posix.join('static', 'img/[name].[hash:7].[ext]')
  50. }
  51. }
  52. ]
  53. }
  54. }