forgeplus-react/config/webpack.server.js

29 lines
938 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const path = require("path");
const nodeExternals = require("webpack-node-externals");
const serverConfig = {
target:"node", //由于输出代码的运行环境是node源码中依赖的node原生模块没必要打包进去为了不把nodejs内置模块打包进输出文件中例如 fs net模块等
mode: "development",
entry: path.resolve(__dirname,"../server/index.js"),
output:{
filename:"bundle.js",
path: path.resolve(__dirname,"../buildserver")
},
externals:[nodeExternals()], //为了不把node_modules目录下的第三方模块打包进输出文件中,因为nodejs默认会去node_modules目录下去寻找和使用第三方模块。
module:{
rules:[
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader",
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
]
}
};
module.exports = serverConfig;