webpack.config.js 1.6 KB

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