PCF项目没有配置用于处理此文件CSS的加载程序
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正在创建一个PCF项目。
在我的软件包中
。
因此,我搜索了如何将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
然后,我将其添加到规则中:
I NPM RUN构建,并且可以使用!
I am creating a PCF project.
In my package.json, I have:
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:
I npm run build again and it works!