webpack.config.core.js 892 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. const webpack = require('webpack')
  2. const path = require('path')
  3. const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
  4. module.exports = (env, argv) => {
  5. const config = {
  6. entry: './src/LSPlugin.core.ts',
  7. devtool: 'eval',
  8. module: {
  9. rules: [
  10. {
  11. test: /\.tsx?$/,
  12. use: 'ts-loader',
  13. exclude: /node_modules/,
  14. },
  15. ],
  16. },
  17. resolve: {
  18. extensions: ['.tsx', '.ts', '.js'],
  19. },
  20. plugins: [
  21. new webpack.ProvidePlugin({
  22. process: 'process/browser',
  23. }),
  24. ],
  25. output: {
  26. library: 'LSPlugin',
  27. libraryTarget: 'umd',
  28. filename: 'lsplugin.core.js',
  29. path: path.resolve(__dirname, '../resources/js'),
  30. },
  31. }
  32. if (argv.mode === 'production') {
  33. delete config.devtool
  34. config.plugins.push(new BundleAnalyzerPlugin())
  35. }
  36. return config
  37. }