【发布时间】:2020-03-04 08:39:40
【问题描述】:
坦率地说,我都试过了。我不是 Webpack 的高手,但是这些年来我在配置新项目方面似乎相处得很好。
我现在似乎无法将 NewRelic 服务设置到现有的 Node/Typescript/Express/Webpack 应用程序中。
就目前而言,我的应用程序被很好地捆绑到我的 /dist 文件夹中的单个文件中,并且运行快速灵活。似乎 New Relic 推出的这个“节点代理”不能很好地与 Typescript 导入配合使用。
Webpack 配置
const path = require('path');
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
const NodemonPlugin = require ('nodemon-webpack-plugin');
module.exports = (env = {}) => {
const config = {
entry: ['./src/app.ts'],
mode: env.development ? 'development' : 'production',
target: 'node',
devtool: env.development ? 'inline-source-map' : false,
resolve: {
extensions: ['.ts', '.js'],
modules: ['node_modules', 'src', 'package.json'],
},
module: {
rules: [
{
test: /\.ts$/,
use: ['ts-loader', 'eslint-loader'],
// exclude: /node_modules/,
},
],
},
plugins: [],
externals: [ 'newrelic', nodeExternals() ]
};
if (env.nodemon) {
config.watch = true;
config.plugins.push(new NodemonPlugin())
}
return config;
};
- 存在标准的 /project_root/.newrelic 文件
- CircleCi 选择了这个项目并从 package.json ==> "webpack" 运行 "build:ci" 脚本
- 输出是/dist/main.js
参考资料
https://docs.newrelic.com/docs/agents/nodejs-agent/installation-configuration/install-nodejs-agent
https://docs.newrelic.com/docs/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration
https://discuss.newrelic.com/t/node-agent-fails-with-webpack/24874
【问题讨论】:
标签: node.js typescript express newrelic