坦率地说,我已经尝试了全部。我并不是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