webpack.config.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. const path = require('path');
  2. const fs = require('fs');
  3. const webpack = require('webpack');
  4. const ExtraWatchWebpackPlugin = require('extra-watch-webpack-plugin');
  5. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  6. const sharedConfig = {
  7. module: {
  8. rules: [
  9. {
  10. test: /\.(woff2?|ttf|otf|eot|svg|html|ico)$/,
  11. use: [{
  12. loader: 'file-loader',
  13. options: { name: '[name].[ext]' }
  14. }]
  15. },
  16. {
  17. test: /\.(s*)css$/,
  18. use: [
  19. MiniCssExtractPlugin.loader,
  20. { loader: 'css-loader', options: { sourceMap: false } },
  21. { loader: 'resolve-url-loader', options: { sourceMap: false } },
  22. { loader: 'sass-loader', options: { sourceMap: false } },
  23. ]
  24. }
  25. ]
  26. },
  27. plugins: [
  28. new ExtraWatchWebpackPlugin({
  29. files: [
  30. './build/**/*.scss',
  31. './build/**/*.html'
  32. ],
  33. }),
  34. new webpack.DefinePlugin({
  35. __BUILD_TIMESTAMP__: webpack.DefinePlugin.runtimeValue(() => `${new Date().valueOf()}`, true),
  36. __RCSB_MOLSTAR_VERSION__: webpack.DefinePlugin.runtimeValue(() => JSON.stringify(require('./package.json').version), true),
  37. 'process.env.DEBUG': JSON.stringify(process.env.DEBUG)
  38. }),
  39. new MiniCssExtractPlugin({ filename: 'app.css' })
  40. ],
  41. resolve: {
  42. modules: [
  43. 'node_modules',
  44. path.resolve(__dirname, 'build/src/')
  45. ],
  46. },
  47. watchOptions: {
  48. aggregateTimeout: 750
  49. },
  50. devtool: ''
  51. }
  52. module.exports = [
  53. {
  54. node: { fs: 'empty' },
  55. entry: path.resolve(__dirname, `build/src/structure-viewer/index.js`),
  56. output: {
  57. library: 'app',
  58. libraryTarget: 'umd',
  59. filename: `app.js`,
  60. path: path.resolve(__dirname, `build/dist/structure-viewer`)
  61. },
  62. ...sharedConfig
  63. },
  64. ]