Nessuna descrizione

webpack.config.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. const fs = require('fs');
  2. const path = require('path');
  3. module.exports = ({ config }) => {
  4. config.module.rules.push({
  5. test: /\.stories\.tsx?$/,
  6. loaders: [require.resolve('@storybook/source-loader')],
  7. enforce: 'pre',
  8. });
  9. config.module.rules.push({
  10. test: /\.less$/,
  11. include: /node_modules|antd\.less/,
  12. use: [
  13. "style-loader",
  14. "css-loader",
  15. {
  16. loader: "less-loader",
  17. options: {
  18. javascriptEnabled: true
  19. }
  20. }
  21. ]
  22. });
  23. config.module.rules.push({
  24. test: /\.less$/,
  25. use: [
  26. 'style-loader',
  27. {
  28. loader: 'css-loader',// translates CSS into CommonJS
  29. options: {
  30. modules: {
  31. localIdentName: '[name]__[local]___[hash:base64:5]',
  32. },
  33. }
  34. },
  35. 'postcss-loader',
  36. {
  37. loader: 'less-loader',
  38. options: {
  39. javascriptEnabled: true,
  40. },
  41. }],
  42. exclude: /node_modules|antd\.less/,
  43. });
  44. config.module.rules.push({
  45. test: /\.(ts|tsx)$/,
  46. use: [
  47. {
  48. loader: require.resolve('babel-loader'),
  49. options: {
  50. presets: [['react-app', { flow: false, typescript: true }]],
  51. "plugins": [
  52. ["import", { "libraryName": "antd", "style": true }]
  53. ]
  54. }
  55. },
  56. // Optional
  57. {
  58. loader: require.resolve("react-docgen-typescript-loader")
  59. },
  60. ]
  61. });
  62. config.resolve.extensions.push(".ts", ".tsx");
  63. config.resolve.alias = {
  64. ...config.resolve.alias,
  65. '@': `${path.resolve(fs.realpathSync(process.cwd()), './src')}`,
  66. '@components': `${path.resolve(fs.realpathSync(process.cwd()), './src')}/components`,
  67. }
  68. config.output.library = "[name]";
  69. return config;
  70. };