webpack.config.js 835 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const path = require('path');
  2. module.exports = (env, argv) => {
  3. const isProduction = argv.mode === 'production';
  4. return {
  5. entry: './src/index.ts',
  6. output: {
  7. filename: 'amf.min.js',
  8. path: path.resolve(__dirname, 'dist'),
  9. },
  10. resolve: {
  11. extensions: ['.ts', '.js'],
  12. alias: {
  13. '@': path.resolve(__dirname, 'src/'),
  14. },
  15. },
  16. module: {
  17. rules: [
  18. {
  19. test: /\.ts$/,
  20. use: 'ts-loader',
  21. exclude: /node_modules/,
  22. },
  23. {
  24. test: /\.css$/i,
  25. use: ['style-loader', 'css-loader'],
  26. },
  27. ],
  28. },
  29. optimization: {
  30. minimize: isProduction,
  31. },
  32. devServer: {
  33. static: path.join(__dirname, 'dist'),
  34. compress: true,
  35. port: 8080,
  36. open: true,
  37. hot: true,
  38. },
  39. };
  40. };