如何在 NodeJs 上搭建 React 开发环境
1个回答
展开全部
何搭建 nodereact 发环境
何搭建 nodereact 发环境
var path = require("path");
var webpack = require('webpack');
module.exports = {
entry: { app: ['./app/main.jsx'] },
output: {
path: path.resolve(__dirname, "./build"),
publicPath: "",
filename: "bundle.js"
},
resolve: {
extensions: ['','.js','.jsx']
},
module: {
loaders: [
{test:/\.jsx$/, loaders:['jsx?harmony']}
],
//使用ES6才需要添加loaders
loaders:[
{
test: /\.jsx?$/,
loader: 'babel',
include: ROOT_PATH,
query: {
//添加两presents 使用两种presets处理js或者jsx文件
presets: ['es2015', 'react']
}
}
]
},
devServer: {
historyApiFallback: true,
hot: true,
inline: true,
progress: true
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE.ENV':"development"
}),
new webpack.HotModuleReplacementPlugin()
]
};
何搭建 nodereact 发环境
var path = require("path");
var webpack = require('webpack');
module.exports = {
entry: { app: ['./app/main.jsx'] },
output: {
path: path.resolve(__dirname, "./build"),
publicPath: "",
filename: "bundle.js"
},
resolve: {
extensions: ['','.js','.jsx']
},
module: {
loaders: [
{test:/\.jsx$/, loaders:['jsx?harmony']}
],
//使用ES6才需要添加loaders
loaders:[
{
test: /\.jsx?$/,
loader: 'babel',
include: ROOT_PATH,
query: {
//添加两presents 使用两种presets处理js或者jsx文件
presets: ['es2015', 'react']
}
}
]
},
devServer: {
historyApiFallback: true,
hot: true,
inline: true,
progress: true
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE.ENV':"development"
}),
new webpack.HotModuleReplacementPlugin()
]
};
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询