博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
react: typescript-webpack项目基本配置
阅读量:6598 次
发布时间:2019-06-24

本文共 3152 字,大约阅读时间需要 10 分钟。

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/**/*"  ]}

 

转载于:https://www.cnblogs.com/Nyan-Workflow-FC/p/10383820.html

你可能感兴趣的文章
力扣算法题—085最大矩阵
查看>>
mysql多实例
查看>>
北京智控美信(长春)数据中心应聘总结
查看>>
C指针分析详解
查看>>
svs 在创建的时候 上传文件夹 bin obj 这些不要提交
查看>>
深度优先搜索-----部分和问题
查看>>
javascript 数组方法总结
查看>>
document.location.search 的作用
查看>>
mysql-用命令导出、导入表结构或数据
查看>>
不要从栈上返回一个局部变量的引用
查看>>
input点击链接另一个页面,各种操作
查看>>
TreeView
查看>>
Tinkphp
查看>>
向网页中嵌入百度地图
查看>>
EntityFrameworkCore 一对一 && 一对多 && 多对多配置
查看>>
How to temporally disable IDE tools (load manually)
查看>>
JS-复习整理
查看>>
Vue.js学习 Item4 -- 数据双向绑定
查看>>
几种排序方式的java实现(01:插入排序,冒泡排序,选择排序,快速排序)
查看>>
如何书写高质量的jQuery代码
查看>>