webpack.config.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. const path = require('path');
  2. const commonConfig = {
  3. module: {
  4. rules: [{
  5. test: /\.svg$/,
  6. issuer: /\.[jt]sx?$/,
  7. use: [{
  8. loader:'@svgr/webpack',
  9. options: {
  10. expandProps: "end",
  11. svgoConfig: {}
  12. }
  13. }]
  14. },{
  15. test: /\.(html|ico)$/,
  16. use: [{
  17. loader: 'file-loader',
  18. options: { name: '[name].[ext]' }
  19. }]
  20. },{
  21. test: /\.(graphql|gql)$/,
  22. loader: 'raw-loader'
  23. },{
  24. test: /\.tsx?$/,
  25. loader: 'ts-loader',
  26. exclude: /node_modules/
  27. },{
  28. test: /\.jsx?$/,
  29. loader: 'babel-loader',
  30. exclude: /node_modules/
  31. }, {
  32. test: /\.s?css$/,
  33. use: ['style-loader', {
  34. loader: 'css-loader',
  35. options: {
  36. modules: {
  37. localIdentName:'[local]'
  38. }
  39. }
  40. },{
  41. loader: 'sass-loader',
  42. options: {
  43. sourceMap: true
  44. }
  45. }]
  46. }
  47. ]
  48. },
  49. resolve: {
  50. extensions: [ '.tsx', '.ts', '.js', '.jsx' ],
  51. fallback: {
  52. fs: false,
  53. buffer: require.resolve('buffer'),
  54. crypto: require.resolve('crypto-browserify'),
  55. path: require.resolve('path-browserify'),
  56. stream: require.resolve('stream-browserify')
  57. }
  58. }
  59. };
  60. const appConfig = {
  61. ...commonConfig,
  62. entry: {
  63. 'app':'./lib/app.js'
  64. },
  65. mode: "production",
  66. output: {
  67. filename: '[name].js',
  68. library: 'RcsbFv3D',
  69. libraryTarget: 'umd',
  70. umdNamedDefine: true,
  71. path: path.resolve(__dirname, 'build')
  72. },
  73. devtool: 'source-map'
  74. }
  75. module.exports = [appConfig];