webpack.config.js 1.7 KB

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