Sendgrid Node.js库不能与React一起工作
Sendgrid Node.js library doesn't work with React
我需要帮助。我试图使用node.js来处理在我的网站上发送电子邮件。我希望我的电子邮件表单继续并发送电子邮件提交,而不是使用基本的"mailto"动作。我有Sendgrid作为我的电子邮件服务来处理API和其他服务器端任务。
我一直得到这个错误,我认为这是一个Webpack问题。在这里输入图像描述我还将发布几行代码。
你知道我该怎么做吗?
//Webpack。配置文件
"use strict";
var webpack = require('webpack');
var loaders = require('./webpack.loaders');
var HtmlWebpackPlugin = require('html-webpack-plugin');
const HOST = process.env.HOST || "127.0.0.1";
const PORT = process.env.PORT || "8888";
// global css
loaders.push({
test: /['/''](node_modules|global)['/''].*'.css$/,
loaders: [
'css-loader!autoprefixer-loader?browsers=last 2 versions',
'style-loader!css-loader!autoprefixer-loader',
'style?sourceMap',
'css'
]
});
//local sass modules
loaders.push({
test: /['/'']src['/''].*'.sass/,
loaders: [
'style?sourceMap',
'css-loader!autoprefixer-loader?browsers=last 2 versions',
'style-loader!css-loader!autoprefixer-loader',
'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]',
'sass'
]
});
//local css modules
loaders.push({
test: /['/'']src['/''].*'.css/,
loaders: [
'style?sourceMap',
'css-loader!autoprefixer-loader?browsers=last 2 versions',
'style-loader!css-loader!autoprefixer-loader',
'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]'
]
});
module.exports = {
entry: [
`webpack-dev-server/client?http://${HOST}:${PORT}`,
`webpack/hot/only-dev-server`,
`./src/index.jsx` // Your appʼs entry point
],
devtool: process.env.WEBPACK_DEVTOOL || 'cheap-module-source-map',
output: {
path:__dirname,
filename: './src/bundle.js'
},
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
loaders
},
devServer: {
// do not print bundle build stats
noInfo: true,
// enable HMR
hot: true,
// embed the webpack-dev-server runtime into the bundle
inline: true,
// serve index.html in place of 404 responses to allow HTML5 history
historyApiFallback: true,
port: PORT,
host: HOST
},
plugins: [
new webpack.NoErrorsPlugin(),
new webpack.HotModuleReplacementPlugin(),
]
};
我找到了这个问题的解决方案
这不是一个问题,你的webpack配置只需要一个json加载器,见这个问题:
https://github.com/webpack/webpack/issues/303我决定自己添加{ test: /'.json$/, loader: 'json'}
到我的webpackloaders
你也可能需要做npm install json-loader --module-bind json
相关文章:
- 将jQuery UI Timepicker Addon与React一起使用
- 将现有的WebView JavascriptInterface与React Native一起使用
- 将 react-redux 与基于事件的第三方库一起使用的最佳方法是什么?
- 如何将Bootstrap npm包与React一起使用
- CKEditor如何与React.js一起使用,以允许React识别它
- 使用Realm React Native查找Realm文件的路径,以便与Realm Browser一起使用
- 如何与Electron一起使用React路由器
- 如何让两个不相关的 React 组件一起工作
- 如何将 Redux 的提供程序与 React 一起使用
- 将 React 与 Nashorn 一起使用会抛出“ReferenceError: 'console' is not d
- 将 React 与工具创建的 SVG 一起使用
- 将去抖动器与 React 事件一起使用
- 将静态 HTML 与 React 一起使用
- React 渲染无法与 createElement 一起使用
- 将 React 的不可变助手与 Immutable.js一起使用
- 当将 onChange 与 React 一起使用时,空格不会被注册
- 我如何让介绍js与React一起工作
- 如何使vanilla Bootstrap在Node上与React一起工作
- Sendgrid Node.js库不能与React一起工作
- MaterializeCSS选择框,如何让它与react一起工作