webpack.config.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. var path = require('path')
  2. var webpack = require('webpack')
  3. var HtmlWebpackPlugin = require('html-webpack-plugin')
  4. var isProduction = process.env.NODE_ENV === 'production'
  5. var config = {
  6. entry: './demo/demo.js',
  7. output: {
  8. path: path.join(__dirname, './demo-dist'),
  9. filename: 'demo.js'
  10. },
  11. module: {
  12. loaders: [
  13. {
  14. test: /\.vue$/,
  15. loader: 'vue-loader'
  16. },
  17. {
  18. test: /\.css$/,
  19. loader: 'style-loader!css-loader'
  20. }
  21. ]
  22. },
  23. externals: {
  24. vue: 'Vue'
  25. },
  26. plugins: [
  27. new webpack.DefinePlugin({
  28. 'process.env':{
  29. 'NODE_ENV': JSON.stringify('dev')
  30. }
  31. }),
  32. new webpack.optimize.OccurrenceOrderPlugin(),
  33. new HtmlWebpackPlugin({
  34. template: 'demo/index.html',
  35. filename: 'index.html'
  36. })
  37. ],
  38. devServer: {
  39. contentBase: path.join(__dirname, './demo'),
  40. compress: false,
  41. port: 9090
  42. }
  43. }
  44. if (isProduction) {
  45. config.plugins.push(
  46. new webpack.optimize.UglifyJsPlugin({
  47. compress: {
  48. warnings: false
  49. }
  50. })
  51. )
  52. }
  53. module.exports = config