我正在尝试将服务器端代码与target: node
捆绑在一起,但代码未被转换(我在构建文件中看到了源代码),并且只有没有任何导入模块的条目文件。
// webpack.config.server.dev.babel.js
import path from 'path'
const SRC = path.resolve(__dirname, '../server')
const BUILD = path.resolve(__dirname, '../build/')
const babelConfig = {
babelrc: false,
presets: [['env', {
targets: { node: 'current' },
modules: false,
//useBuiltIns: true
}], 'react']
}
export default {
context: SRC,
entry: './',
output: {
path: BUILD,
filename: 'server.bundle.js'
},
target: 'node',
module: {
noParse: /node_modules/,
rules: [{
test: /\.jsx?$/,
use: {
loader: 'babel-loader',
options: babelConfig
}
}, {
test: /\.css$/,
use: [
'style-loader',
{
loader: 'css-loader/locals',
options: {
modules: true,
localIdentName: '[folder]__[local]--[hash:base64:5]',
camelCase: true
}
}
]
}]
},
devtool: 'source-map',
performance: { hints: false },
resolve: {
modules: ['node_modules', 'shared'],
extensions: ['.js', '.jsx', '.json']
}
}
我做错了什么?
答案 0 :(得分:0)
config.module.noParse = true
导致了这种行为。