在开发outlook加载项时。
我会添加顺风,这是我跟踪的the tuto
在package.json中,我得到了这些脚本
"scripts": {
"build": "webpack --mode production",
"build:dev": "webpack --mode development",
"dev-server": "webpack serve --mode development",
...
},
然后在webpack.config.js中
const config = {
devtool: "source-map",
entry: {
polyfill: ["core-js/stable", "regenerator-runtime/runtime"],
vendor: ["react", "react-dom", "core-js", "@fluentui/react"],
taskpane: ["react-hot-loader/patch", "./src/taskpane/index.tsx", "./src/taskpane/taskpane.html"],
commands: "./src/commands/commands.ts",
},
output: {
clean: true,
},
resolve: {
extensions: [".ts", ".tsx", ".html", ".js"],
},
module: {
rules: [
{
test: /\.css$/i,
include: '/src',
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
{
test: /\.ts$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-typescript"],
},
},
},
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: ["react-hot-loader/webpack", "ts-loader"],
},
{
test: /\.html$/,
exclude: /node_modules/,
use: "html-loader",
},
{
test: /\.(png|jpg|jpeg|gif|ico)$/,
type: "asset/resource",
generator: {
filename: "assets/[name][ext][query]",
},
},
],
},
plugins: [
...
}),
new HtmlWebpackPlugin({
filename: "taskpane.html",
template: "./src/taskpane/taskpane.html",
chunks: ["taskpane", "vendor", "polyfills"],
}),
new HtmlWebpackPlugin({
filename: "commands.html",
template: "./src/commands/commands.html",
chunks: ["commands"],
}),
new webpack.ProvidePlugin({
Promise: ["es6-promise", "Promise"],
}),
],
devServer: {
hot: true,
headers: {
"Access-Control-Allow-Origin": "*",
},
server: {
type: "https",
options: env.WEBPACK_BUILD || options.https !== undefined ? options.https : await getHttpsOptions(),
},
port: process.env.npm_package_config_dev_server_port || 3000,
},
};
在postcss.config.js中:
const tailwindcss = require('tailwindcss');
module.exports = {
plugins: [
'postcss-preset-env',
tailwindcss
],
};
最后是tailwind.config.js
/**@type {import('tailwindcss ').Config} */
module.exports = {
content: ['./dist/*.html'],
theme: {
extend: {},
},
plugins: [],
};
当我尝试应用一个tailwind css类时,什么也没有发生,当我在devTools中检查tailwind css颜色标记是否被导入时,我也没有看到任何东西。
我在index.css中导入顺风组件
@tailwind base;
@tailwind components;
@tailwind utilities;
然后我在taskpane.html中导入index.css
<link href="index.css" rel="stylesheet" type="text/css" />
以下是我的项目文件夹配置:
1条答案
按热度按时间6kkfgxo01#
根据您发布的教程,您需要在您的dist/index.html中执行此操作
style.css需要导入index.js文件中。
只是指出什么是对教程,不确定如果教程是有效的,虽然。