webpack.config.js 2.0 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: /\.(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. 'css-loader', 'resolve-url-loader', 'sass-loader'
  21. ]
  22. }
  23. ]
  24. },
  25. plugins: [
  26. new ExtraWatchWebpackPlugin({
  27. files: [
  28. './build/**/*.scss',
  29. './build/**/*.html'
  30. ],
  31. }),
  32. new webpack.DefinePlugin({
  33. __VERSION__: webpack.DefinePlugin.runtimeValue(() => JSON.stringify(require('./node_modules/molstar/package.json').version), true),
  34. __VERSION_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. ]