webpack.config.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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)$/,
  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.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
  34. 'process.env.DEBUG': JSON.stringify(process.env.DEBUG)
  35. }),
  36. new MiniCssExtractPlugin({ filename: 'app.css' })
  37. ],
  38. resolve: {
  39. modules: [
  40. 'node_modules',
  41. path.resolve(__dirname, 'build/src/')
  42. ],
  43. },
  44. }
  45. module.exports = [
  46. {
  47. node: { fs: 'empty' },
  48. entry: path.resolve(__dirname, `build/src/structure-viewer/index.js`),
  49. output: {
  50. library: 'app',
  51. libraryTarget: 'umd',
  52. filename: `app.js`,
  53. path: path.resolve(__dirname, `build/dist/structure-viewer`)
  54. },
  55. ...sharedConfig
  56. },
  57. ]