美文网首页
start react+webpack+typescript

start react+webpack+typescript

作者: zwebbin | 来源:发表于2021-02-23 11:16 被阅读0次

    webpack加载css文件

    Module parse failed: Unexpected token (1:0)
    You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.

    css-loader-error.png
    参考链接:
    https://stackoverflow.com/questions/42530582/css-module-parse-failed css-module-parse.png

    webpack无法正确加载css文件,需要在webpack.config.ts中加入css-loader

    // 首先要安装style-loader css-loader
    npm install --save-dev style-loader css-loader
    

    修改配置

     module: {
        rules: [
          {
             /** 其它loader  **/
          },
          {
            test: /\.css$/,
            exclude: /node_modules/,
            use: ['style-loader', 'css-loader'],
          },
        ],
      },
    

    Eslint忽略css文件

    [unknown]: Parsing error: ';' expected.

    css-parse-error.png
    https://stackoverflow.com/questions/63596271/webpack-with-css-loader-parsing-error-expected

    修改webpack.config.ts,配置eslint不检查css文件

    plugins: [
        new ForkTsCheckerWebpackPlugin({
          async: false,
          eslint: {
            files: ['./src/**/*.js', './src/**/*.ts', './src/**/*.tsx'],
          },
        }),
      ],
    

    相关文章

      网友评论

          本文标题:start react+webpack+typescript

          本文链接:https://www.haomeiwen.com/subject/kalrfltx.html