webpack.config.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. __VERSION__: webpack.DefinePlugin.runtimeValue(() => JSON.stringify(require('./node_modules/molstar/package.json').version), true),
  36. __VERSION_TIMESTAMP__: webpack.DefinePlugin.runtimeValue(() => `${new Date().valueOf()}`, true),
  37. __RCSB_MOLSTAR_VERSION__: webpack.DefinePlugin.runtimeValue(() => JSON.stringify(require('./package.json').version), true),
  38. 'process.env.DEBUG': JSON.stringify(process.env.DEBUG)
  39. }),
  40. new MiniCssExtractPlugin({ filename: 'app.css' })
  41. ],
  42. resolve: {
  43. modules: [
  44. 'node_modules',
  45. path.resolve(__dirname, 'build/src/')
  46. ],
  47. },
  48. watchOptions: {
  49. aggregateTimeout: 750
  50. },
  51. devtool: ''
  52. }
  53. module.exports = [
  54. {
  55. node: { fs: 'empty' },
  56. entry: path.resolve(__dirname, `build/src/structure-viewer/index.js`),
  57. output: {
  58. library: 'app',
  59. libraryTarget: 'umd',
  60. filename: `app.js`,
  61. path: path.resolve(__dirname, `build/dist/structure-viewer`)
  62. },
  63. ...sharedConfig
  64. },
  65. ]