office-js + outlook-web-addins + Webpack + Production

office-js + outlook-web-addins + Webpack + Production

I am totally new to NodeJS, Webpack and specially to Outlook Addin. So, I created my Outlook Addin using basic tutorials from&nbsp;<a href="https://docs.microsoft.com/en-us/outlook/add-ins/addin-tutorial" target="_blank">https://docs.microsoft.com/en-us/outlook/add-ins/addin-tutorial</a>, all went well.

I am totally new to NodeJS, Webpack and specially to Outlook Addin. So, I created my Outlook Addin using basic tutorials from https://docs.microsoft.com/en-us/outlook/add-ins/addin-tutorial, all went well.

However, when it came to deployment on Production, I struggled a lot. I put all my code up on Production (Ubuntu instance). First tested a simple NodeJS "hello World" app on Port:8080 and it worked just fine. Then I tried to start my Outlook Addin, just like I was doing locally, it started on port 3000, but I needed to run it on 8080 and in the background. So, I used "PM2", and here comes the "WALL".

  • pm2 start src/index.js doesn't work for me, as the inside Office.onReady or any other reference to Office does not work, throws undefined Office error.

I tried pm2 run-script build, (after modifications in package.json and webpack.prod.js files)

  • However, I am still getting the same error when try to run pm2 start dist/app.bundle.js

So, please guide me which file should I reference to when using pm2 start {filename/path}?

Here are some configurations that I am using, webpack.common.js

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

module.exports = { entry: { polyfill: 'babel-polyfill', app: './src/index.js', 'function-file': './function-file/function-file.js' }, module: { rules: [ { test: /.js$/, exclude: /node_modules/, use: 'babel-loader' }, { test: /.html$/, exclude: /node_modules/, use: 'html-loader' }, { test: /.(png|jpg|jpeg|gif)$/, use: 'file-loader' } ] }, plugins: [ new CleanWebpackPlugin(['dist']), new HtmlWebpackPlugin({ title: 'Production' }), new HtmlWebpackPlugin({ template: './index.html', chunks: ['polyfill', 'app'] }), new HtmlWebpackPlugin({ template: './function-file/function-file.html', filename: 'function-file/function-file.html', chunks: ['function-file'] }), ], output: { filename: '[name].bundle.js', path: path.resolve(__dirname, 'dist') } };

webpack.prod.js

 const merge = require('webpack-merge');
 const common = require('./webpack.common.js');

module.exports = merge(common, { mode: 'production', devtool: 'source-map' });


node-js webpack

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Hire Node.js Developers And How Much Does It Cost?

A Guide to Hire Node.js Developers who can help you create fast and efficient web applications. Also, know how much does it cost to hire Node.js Developers.

Hire Node.JS Developers | Skenix Infotech

We are providing robust Node.JS Development Services with expert Node.js Developers. Get affordable Node.JS Web Development services from Skenix Infotech.

Hands on with Node.Js Streams | Examples & Approach

The practical implications of having Streams in Node.js are vast. Nodejs Streams are a great way to handle data chunks and uncomplicate development.

Node.js Performance: Node.js vs. Io.js

You may already be aware that Raygun uses Node.JS for our API nodes that receive your precious crash reporting data (we also do node.js crash reporting if you’re interested). We’ve peaked in the past at more than 110,000 requests per second coming...

Node.js Live | Node.js Docker Tutorial | Dockerizing Node.js App|Node.js Training|Edureka

🔥 Node.js Certification Training: https://www.edureka.co/nodejs-certification-training This Edureka video on 'Node.js Docker Tutorial' will help you in learn...