Ei kuvausta

webpack.config.js 1.6KB

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