1、webpack.config.js basic
const webpack = require('webpack');const autoprefixer = require('autoprefixer');const HtmlWebpackPlugin = require('html-webpack-plugin');module.exports = { entry: "./src/index.tsx", output: { filename: "bundle.js", path: __dirname + "/dist" }, // Enable sourcemaps for debugging webpack's output. devtool: "source-map", resolve: { // Add '.ts' and '.tsx' as resolvable extensions. extensions: [".ts", ".tsx", ".js", ".json"] }, module: { rules: [ // All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'. { test: /\.tsx?$/, loader: "awesome-typescript-loader", options: { plugins: [ ['import', [{ libraryName: 'antd', style: true }]], // import less ], } }, // All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'. { test: /\.js$/, enforce: "pre", loader: "source-map-loader" }, { test: /\.less$/, use: [ require.resolve('style-loader'), require.resolve('css-loader'), { loader: require.resolve('postcss-loader'), options: { ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options plugins: () => [ require('postcss-flexbugs-fixes'), autoprefixer({ browsers: [ '>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9', // React doesn't support IE8 anyway ], flexbox: 'no-2009', }), ], }, }, { loader: require.resolve('less-loader'), options: { modifyVars: { "@primary-color": "#000000" }, }, }, ], }, // "style" loader turns CSS into JS modules that inject
2、tsconfig.js
{ "compilerOptions": { "baseUrl": ".", "outDir": "dist", "rootDir": "src", "module": "esnext", "target": "es5", "lib": [ "es6", "dom" ], "sourceMap": true, "allowJs": true, "jsx": "react", "moduleResolution": "node", "forceConsistentCasingInFileNames": true, "noImplicitReturns": true, "noImplicitThis": true, "noImplicitAny": true, "importHelpers": true, "strictNullChecks": true, "suppressImplicitAnyIndexErrors": true, "noUnusedLocals": true }, "exclude": [ "node_modules", "dist", "scripts", "acceptance-tests", "webpack", "jest", "src/setupTests.ts" ], "include": [ "./src/**/*" ]}