Reputation: 59
My main code. I has "require('node-rsa')" which in node_modules folder. Is it possible to create one file from this code?
a.js
var testFunct = function test(message) {
const NodeRSA = require('node-rsa');
const key = new NodeRSA();
var k = key.generateKeyPair();
var p = k.exportKey('pkcs1');
return p};
console.log(testFunct())
package.json
{
"name": "pol",
"version": "1.0.0",
"description": "",
"main": "a.js",
"dependencies": {
"node-rsa": "^1.1.1",
"build": "webpack a.js b.js"
},
"devDependencies": {
"webpack": "^5.58.2"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
webpack.config.js
module.exports = {
entry: ['a.js'],
output: {
path: './build',
filename: 'bundle.js'
}
}
Upvotes: 0
Views: 71
Reputation: 3782
Add this entry to the scripts
section of your package.json:
"build": "webpack"
This will trigger webpack, when you run the build action.
Upvotes: 1