PCF项目没有配置用于处理此文件CSS的加载程序

发布于 2025-02-13 01:53:37 字数 2317 浏览 3 评论 0原文

I NPM安装了一个反应时间表库: https://github.com/veysiyildiz/vertical-timeline-component-反应#readme

npm i vertical-timeline-component-for-react

当我使用时间表示例时:

import { Timeline, TimelineItem }  from 'vertical-timeline-component-for-react';

<Timeline lineColor={'#ddd'}>
  <TimelineItem
    key="001"
    dateText="11/2010 – Present"
    style={{ color: '#e86971' }}
  >
...

然后i npm run构建。我有一个错误:

ERROR in ./node_modules/vertical-timeline-component-for-react/dist/TimelineItem.css 1:0
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. See https://webpack.js.org/concepts#loaders
> .body-container {
|   position: relative;
|   margin-left: 30px;

这是我的webpack.config.cs文件:

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    mode: 'development',
    entry: path.resolve(__dirname, './CaseJourney/CaseJourneyControl/Pages/CaseJourneyDisplayPage.tsx'),
    output: {
        path: path.resolve(__dirname, 'output'),
        filename: 'bundle.js'
    },
    resolve: {
        extensions: ['.js', '.jsx', ".tsx", ".ts", ".js"]
    },
    module: {
        rules: [{
                test: /\.(js|jsx)$/,
                use: {
                    loader: 'babel-loader'
                },
                exclude: /node_modules/
            },
            {
                test: /\.css$/, use: ["style-loader", "css-loader"] 
            },
            {
                test: /\.tsx?$/,
                use: [
                    {
                        loader: "ts-loader",
                        options: {
                            configFile: tsconfigName,
                            transpileOnly: true,
                        },
                    },
                ],
                exclude: /node_modules/,
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: "./public/index.html",
            filename: "./index.html"
         })
    ]
}

I npm installed a React timeline library:
https://github.com/veysiyildiz/vertical-timeline-component-for-react#readme

npm i vertical-timeline-component-for-react

When I use the Timeline example:

import { Timeline, TimelineItem }  from 'vertical-timeline-component-for-react';

<Timeline lineColor={'#ddd'}>
  <TimelineItem
    key="001"
    dateText="11/2010 – Present"
    style={{ color: '#e86971' }}
  >
...

And then I npm run build. I get an error:

ERROR in ./node_modules/vertical-timeline-component-for-react/dist/TimelineItem.css 1:0
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. See https://webpack.js.org/concepts#loaders
> .body-container {
|   position: relative;
|   margin-left: 30px;

This is my webpack.config.cs file:

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    mode: 'development',
    entry: path.resolve(__dirname, './CaseJourney/CaseJourneyControl/Pages/CaseJourneyDisplayPage.tsx'),
    output: {
        path: path.resolve(__dirname, 'output'),
        filename: 'bundle.js'
    },
    resolve: {
        extensions: ['.js', '.jsx', ".tsx", ".ts", ".js"]
    },
    module: {
        rules: [{
                test: /\.(js|jsx)$/,
                use: {
                    loader: 'babel-loader'
                },
                exclude: /node_modules/
            },
            {
                test: /\.css$/, use: ["style-loader", "css-loader"] 
            },
            {
                test: /\.tsx?$/,
                use: [
                    {
                        loader: "ts-loader",
                        options: {
                            configFile: tsconfigName,
                            transpileOnly: true,
                        },
                    },
                ],
                exclude: /node_modules/,
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: "./public/index.html",
            filename: "./index.html"
         })
    ]
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

看春风乍起 2025-02-20 01:53:37

我正在创建一个PCF项目。
在我的软件包中

  "scripts": {
    "build": "pcf-scripts build",
    "clean": "pcf-scripts clean",
    "rebuild": "pcf-scripts rebuild",
    "start": "pcf-scripts start",
    "refreshTypes": "pcf-scripts refreshTypes"
  },

因此,我搜索了如何将CSS加载器添加到PCF,并找到了此答案:
https://powerusers.microsoft.com/t5/power-apps-pro-dev-isv/extering-the-pcf-scripts-webpack/td-pback/td-p/383173

因此,我去了NODE_MODULES - &gt; pcf-scripts-&gt; WebPackConfig.js
然后,我将其添加到规则中:

     {
          test: /\.css$/,
          use: ['style-loader', 'css-loader'],
     }
  • 确保您具有NPM安装-Save-DEV样式加载程序CSS-LOADER

I NPM RUN构建,并且可以使用!

I am creating a PCF project.
In my package.json, I have:

  "scripts": {
    "build": "pcf-scripts build",
    "clean": "pcf-scripts clean",
    "rebuild": "pcf-scripts rebuild",
    "start": "pcf-scripts start",
    "refreshTypes": "pcf-scripts refreshTypes"
  },

The build points to pcf-scripts build.

Thus, I searched how to add css loader to pcf and found this answer:
https://powerusers.microsoft.com/t5/Power-Apps-Pro-Dev-ISV/Extending-the-pcf-scripts-webpack/td-p/383173

Thus, I went to node_modules --> pcf-scripts --> webpackConfig.js
Then I added this to the rules:

     {
          test: /\.css$/,
          use: ['style-loader', 'css-loader'],
     }
  • Make sure you have npm install --save-dev style-loader css-loader

I npm run build again and it works!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文