webpack.config.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. const path = require('path');
  2. const HtmlWebpackPlugin = require('html-webpack-plugin');
  3. const CleanWebpackPlugin = require('clean-webpack-plugin');
  4. const CopyWebpackPlugin = require('copy-webpack-plugin');
  5. module.exports = {
  6. entry: './src/index.ts',
  7. devtool: 'inline-source-map',
  8. output: {
  9. filename: 'wcs.js',
  10. path: path.resolve(__dirname, 'dist')
  11. },
  12. optimization: {
  13. splitChunks: {
  14. chunks: 'all'
  15. }
  16. },
  17. devServer: {
  18. contentBase: path.join(__dirname, "dist"),
  19. //port:4090, //指定端口号,默认是8080
  20. host:'0.0.0.0',
  21. //hot:true
  22. },
  23. module: {
  24. rules: [
  25. {
  26. test: /\.tsx?$/,
  27. use: 'ts-loader',
  28. exclude: /node_modules/,
  29. }]
  30. },
  31. resolve: {
  32. extensions: ['.tsx', '.ts', '.js']
  33. },
  34. externals: {
  35. jquery: 'jQuery',
  36. three: 'THREE',
  37. },
  38. plugins: [
  39. new CleanWebpackPlugin(['dist']),
  40. new HtmlWebpackPlugin({
  41. filename: 'index.html',
  42. template: 'index.html',
  43. inject: true
  44. }),
  45. new CopyWebpackPlugin([
  46. {
  47. from: path.resolve(__dirname, 'static'),
  48. to: path.resolve(__dirname, 'dist','static'),
  49. ignore: ['.*']
  50. }])
  51. ]
  52. }