68 lines
1.6 KiB
JavaScript
68 lines
1.6 KiB
JavaScript
const path = require("path");
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
|
const devCerts = require("office-addin-dev-certs");
|
|
|
|
module.exports = async (env, argv) => {
|
|
const isDev = argv.mode === "development";
|
|
const httpsOptions = isDev ? await devCerts.getHttpsServerOptions() : undefined;
|
|
|
|
return {
|
|
entry: {
|
|
taskpane: "./src/taskpane/index.tsx",
|
|
},
|
|
output: {
|
|
path: path.resolve(__dirname, "dist"),
|
|
filename: "[name].bundle.js",
|
|
clean: true,
|
|
},
|
|
resolve: {
|
|
extensions: [".ts", ".tsx", ".js", ".jsx"],
|
|
alias: {
|
|
"@": path.resolve(__dirname, "src"),
|
|
},
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.tsx?$/,
|
|
use: "ts-loader",
|
|
exclude: /node_modules/,
|
|
},
|
|
{
|
|
test: /\.css$/,
|
|
use: ["style-loader", "css-loader"],
|
|
},
|
|
{
|
|
test: /\.(png|jpg|jpeg|gif|svg|ico)$/,
|
|
type: "asset/resource",
|
|
},
|
|
],
|
|
},
|
|
plugins: [
|
|
new HtmlWebpackPlugin({
|
|
template: "./src/taskpane/taskpane.html",
|
|
filename: "taskpane.html",
|
|
chunks: ["taskpane"],
|
|
}),
|
|
new CopyWebpackPlugin({
|
|
patterns: [
|
|
{ from: "assets", to: "assets" },
|
|
{ from: "manifest.xml", to: "manifest.xml" },
|
|
],
|
|
}),
|
|
],
|
|
devServer: {
|
|
port: 3000,
|
|
https: httpsOptions || true,
|
|
headers: {
|
|
"Access-Control-Allow-Origin": "*",
|
|
},
|
|
static: {
|
|
directory: path.resolve(__dirname, "dist"),
|
|
},
|
|
},
|
|
devtool: isDev ? "source-map" : false,
|
|
};
|
|
};
|