就像标题所说的那样,我正在寻找一个可工作的Webpack配置,以查找一个React组件库,该组件通过SASS支持Typescript,SASS和CSS模块。如果有人要在这里分享,我将不胜感激。
答案 0 :(得分:1)
创建tsconfig.json文件
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"sourceMap": true
},
"exclude": [
"node_modules"
]
}
安装开发人员依赖项
npm install webpack webpack-cli webpack-dev-server typescript ts-loader style-loader css-loader sass-loader --save-dev
然后创建webpack.config.js
const path = require('path');
module.exports = {
entry: path.join(__dirname, '/app.ts'),
output: {
filename: 'app.js',
path: __dirname
},
module: {
rules: [
{
test: /\.scss$/,
use: [
'style-loader',
{
loader: "css-loader",
options: {
minimize: true,
sourceMap: true
}
},
{
loader: "sass-loader"
}
]
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/,
},
]
},
resolve: {
extensions: [".tsx", ".ts", ".js"]
},
};