webpack.config.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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: /\.(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: 'sass-loader', options: { sourceMap: false } },
  22. ]
  23. }
  24. ]
  25. },
  26. plugins: [
  27. new ExtraWatchWebpackPlugin({
  28. files: [
  29. './build/**/*.scss',
  30. './build/**/*.html'
  31. ],
  32. }),
  33. new webpack.DefinePlugin({
  34. __BUILD_TIMESTAMP__: webpack.DefinePlugin.runtimeValue(() => `${new Date().valueOf()}`, true),
  35. __RCSB_MOLSTAR_VERSION__: webpack.DefinePlugin.runtimeValue(() => JSON.stringify(require('./package.json').version), true),
  36. 'process.env.DEBUG': JSON.stringify(process.env.DEBUG)
  37. }),
  38. new MiniCssExtractPlugin({ filename: 'app.css' })
  39. ],
  40. resolve: {
  41. modules: [
  42. 'node_modules',
  43. path.resolve(__dirname, 'build/src/')
  44. ],
  45. },
  46. watchOptions: {
  47. aggregateTimeout: 750
  48. },
  49. devtool: ''
  50. }
  51. module.exports = [
  52. {
  53. node: { fs: 'empty' },
  54. entry: path.resolve(__dirname, `build/src/structure-viewer/index.js`),
  55. output: {
  56. library: 'app',
  57. libraryTarget: 'umd',
  58. filename: `app.js`,
  59. path: path.resolve(__dirname, `build/dist/structure-viewer`)
  60. },
  61. ...sharedConfig
  62. },
  63. ]