webpack.config.js 770 B

123456789101112131415161718192021222324252627282930313233343536
  1. const webpack = require('webpack')
  2. const path = require('path')
  3. const version = require('./package.json').version
  4. const argv = require('yargs').argv
  5. let channel = argv.channel || 'beibaoyx'
  6. module.exports = {
  7. entry: {
  8. [`huosdk-${version}`]: './src/index.js'
  9. },
  10. mode: 'production',
  11. module: {
  12. rules: [
  13. {
  14. test: /\.js$/,
  15. exclude: /node_modules/,
  16. loader: 'babel-loader',
  17. options: {
  18. presets: ['env'],
  19. plugins: ['transform-object-rest-spread']
  20. }
  21. }
  22. ]
  23. },
  24. output: {
  25. path: path.resolve(__dirname, `./dist/${channel}`),
  26. filename: '[name].js',
  27. libraryTarget: "commonjs2"
  28. },
  29. plugins: [
  30. new webpack.DefinePlugin({
  31. BUILD_ENV: JSON.stringify(channel)
  32. })
  33. ]
  34. }