webpack.config.js 793 B

1234567891011121314151617181920212223242526272829303132333435
  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.env
  6. console.log("argv.env,channel",channel)
  7. module.exports = {
  8. entry: {
  9. [`qcsdkIAA-${version}`]: './src/index.js'
  10. },
  11. mode: 'production',
  12. module: {
  13. rules: [
  14. {
  15. test: /\.js$/,
  16. exclude: /node_modules/,
  17. loader: 'babel-loader',
  18. options: {
  19. presets: ['env'],
  20. plugins: ['transform-object-rest-spread']
  21. }
  22. }
  23. ]
  24. },
  25. output: {
  26. path: path.resolve(__dirname, `./dist/${channel}`),
  27. filename: '[name].js',
  28. libraryTarget: "commonjs2"
  29. },
  30. plugins: [
  31. new webpack.DefinePlugin({
  32. BUILD_ENV: JSON.stringify(channel)
  33. })
  34. ]
  35. }