webpack.config.js 1.8 KB

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