123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- const fs = require('fs');
- const path = require('path');
-
- module.exports = ({ config }) => {
- config.module.rules.push({
- test: /\.stories\.tsx?$/,
- loaders: [require.resolve('@storybook/source-loader')],
- enforce: 'pre',
- });
- config.module.rules.push({
- test: /\.less$/,
- include: /node_modules|antd\.less/,
- use: [
- "style-loader",
- "css-loader",
- {
- loader: "less-loader",
- options: {
- javascriptEnabled: true
- }
- }
- ]
- });
- config.module.rules.push({
- test: /\.less$/,
- use: [
- 'style-loader',
- {
- loader: 'css-loader',// translates CSS into CommonJS
- options: {
- modules: {
- localIdentName: '[name]__[local]___[hash:base64:5]',
- },
- }
- },
- 'postcss-loader',
- {
- loader: 'less-loader',
- options: {
- javascriptEnabled: true,
- },
- }],
- exclude: /node_modules|antd\.less/,
- });
- config.module.rules.push({
- test: /\.(ts|tsx)$/,
- use: [
- {
- loader: require.resolve('babel-loader'),
- options: {
- presets: [['react-app', { flow: false, typescript: true }]],
- "plugins": [
- ["import", { "libraryName": "antd", "style": true }]
- ]
- }
- },
- // Optional
- {
- loader: require.resolve("react-docgen-typescript-loader")
- },
- ]
- });
- config.resolve.extensions.push(".ts", ".tsx");
- config.resolve.alias = {
- ...config.resolve.alias,
- '@': `${path.resolve(fs.realpathSync(process.cwd()), './src')}`,
- '@components': `${path.resolve(fs.realpathSync(process.cwd()), './src')}/components`,
- }
- config.output.library = "[name]";
- return config;
- };
|