微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Lerna monorepo与Webpack加载打字稿文件有关

如何解决Lerna monorepo与Webpack加载打字稿文件有关

我已经使用Lerna设置了一个monorepo,并且在尝试编译该应用程序时收到以下错误

../ template / src / App.tsx 4:9 模块解析失败:意外的令牌(4:9) 您可能需要适当的加载程序来处理此文件类型,当前没有配置任何加载程序来处理此文件。参见https://webpack.js.org/concepts#loaders

| import React from 'react';
| 
> const App: React.FC = () => {
|     return (
|         <div className="App">

我已经尝试过此问题的解决方案,但似乎不起作用:

You may need an appropriate loader to handle this file type,currently no loaders are configured to process this file."

能否请您介绍一下这个潜在问题?

我已经在完整的webpack.config.js文件上附加了一个链接,因为它很大,但是可以推断出我预计问题出处的区域。

https://codesandbox.io/s/compassionate-sound-uzmmm?file=/src/webpack.config.js

module: {
strictExportPresence: true,rules: [
    { parser: { requireEnsure: false } },{
        test: /\.(js|mjs|jsx|ts|tsx)$/,enforce: 'pre',use: [
            {
                options: {
                    formatter: require.resolve('react-dev-utils/eslintFormatter'),eslintPath: require.resolve('eslint'),emitWarning: isEnvDevelopment,},loader: require.resolve('eslint-loader'),],include: [paths.appSrc,paths.packagesSrc,paths.sharedSrc],{
        oneOf: [
            {
                test: [/\.bmp$/,/\.gif$/,/\.jpe?g$/,/\.png$/],loader: require.resolve('url-loader'),options: {
                    limit: imageInlinesizeLimit,name: 'static/media/[name].[hash:8].[ext]',{
                test: /\.(js|mjs|jsx|ts|tsx)$/,loader: require.resolve('babel-loader'),options: {
                    customize: require.resolve('babel-preset-react-app/webpack-overrides'),presets: ['@babel/preset-env','@babel/preset-react','@babel/preset-typescript'],plugins: [
                        [
                            require.resolve('babel-plugin-named-asset-import'),{
                                loaderMap: {
                                    svg: {
                                        ReactComponent: '@svgr/webpack?-svgo,+titleProp,+ref![path]',cacheDirectory: true,cacheCompression: false,compact: isEnvProduction,{
                test: /\.(js|mjs)$/,exclude: /@babel(?:\/|\\{1,2})runtime/,options: {
                    babelrc: false,configFile: false,compact: false,presets: [[require.resolve('babel-preset-react-app/dependencies'),{ helpers: true }]],sourceMaps: shouldUseSourceMap,inputSourceMap: shouldUseSourceMap,{
                test: cssRegex,exclude: cssModuleRegex,use: getStyleLoaders({
                    importLoaders: 1,sourceMap: isEnvProduction && shouldUseSourceMap,}),sideEffects: true,{
                test: cssModuleRegex,modules: {
                        getLocalIdent: getCSSModuleLocalIdent,{
                test: sassRegex,exclude: sassModuleRegex,use: getStyleLoaders(
                    {
                        importLoaders: 3,'sass-loader',),{
                test: sassModuleRegex,modules: {
                            getLocalIdent: getCSSModuleLocalIdent,{
                loader: require.resolve('file-loader'),exclude: [/\.(js|mjs|jsx|ts|tsx)$/,/\.html$/,/\.json$/],options: {
                    name: 'static/media/[name].[hash:8].[ext]',

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。