• You may need an appropriate loader to handle this file type.


        最近在构建一个typescript+react简单项目的时候遇到了一个问题,运行webpack命令的时候报错You may need an appropriate loader to handle this file type.但是我明明安装了ts的loader

    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" },
                // { test: /.tsx?$/, loader: "ts-loader" },
                // All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
                { enforce: "pre", test: /.js$/, loader: "source-map-loader" }
            ]
        },
        externals: {
            "react": "React",
            "react-dom": "ReactDOM"
        }
    }

    后来发现,当时项目搭建的时候官网让我安装webpack的时候我没有安装,用的全局webpack,项目中未安装,所以我又安装了webpack和webpack-cli,然后就解决了上述问题。

  • 相关阅读:
    spring mvc valid
    记录一次springmvc 404
    用到的 git 命令
    tomcat java.lang.OutOfMemoryError: PermGen space
    angularjs 表单验证 和 页面初始化闪烁
    在jsp中 EL表达式不生效
    关于jsp中使用jstl的问题
    块级元素,内联元素和定位
    java学习第4天
    STL 常用集合算法
  • 原文地址:https://www.cnblogs.com/youngboy-front/p/10341959.html
Copyright © 2020-2023  润新知