webpack.config.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const fs = require('fs')
  2. const path = require('path')
  3. const webpack = require('webpack')
  4. module.exports = {
  5. devtool: 'inline-source-map',
  6. entry: fs.readdirSync(__dirname).reduce((entries, dir) => {
  7. const fullDir = path.join(__dirname, dir)
  8. const entry = path.join(fullDir, 'app.js')
  9. if (fs.statSync(fullDir).isDirectory() && fs.existsSync(entry)) {
  10. entries[dir] = entry
  11. }
  12. return entries
  13. }, {}),
  14. output: {
  15. path: path.join(__dirname, '__build__'),
  16. filename: '[name].js',
  17. chunkFilename: '[id].chunk.js',
  18. publicPath: '/__build__/'
  19. },
  20. module: {
  21. loaders: [
  22. { test: /\.js$/, exclude: /node_modules/, loader: 'babel' },
  23. { test: /\.vue$/, loader: 'vue' }
  24. ]
  25. },
  26. resolve: {
  27. alias: {
  28. vuex: path.resolve(__dirname, '../build/dev-entry')
  29. }
  30. },
  31. plugins: [
  32. new webpack.optimize.CommonsChunkPlugin('shared.js'),
  33. new webpack.DefinePlugin({
  34. 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
  35. })
  36. ]
  37. }