zoukankan      html  css  js  c++  java
  • 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,然后就解决了上述问题。

  • 相关阅读:
    DMR 系统平方根升余弦滚降滤波器设计SRRC及仿真图
    相似项
    第三种主题暗黑系
    汽油性能
    放平心态
    Python 中的哈希表
    第二种主题
    win7旗舰版 一键激活
    java与c++的不同感受
    c代码待用c++代码
  • 原文地址:https://www.cnblogs.com/youngboy-front/p/10341959.html
Copyright © 2011-2022 走看看