webpack.config.js 1.4 KB

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