我准备在Heroku上放一个小应用程序,我正在制作一个生产配置。当我运行npm run build
所有工作。但是,当我运行构建的文件node dist/dist.js
时,我收到错误:
ReferenceError: document is not defined
我应该使用不同的css加载器吗? 我的webpack.deployment.config.js如下:
const path = require('path');
const webpack = require('webpack');
module.exports = {
devtool: 'source-map',
entry: [
'./client/index.js'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: './dist/'
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
minimize: true,
compress: {
warnings: false
},
sourceMap: true
})
],
module: {
loaders: [{
test: /.jsx?$/,
loader: 'babel-loader',
include: path.join(__dirname, 'client'),
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
},
{ test: /\.css$/, loader: "css-loader" },
{ test: /\.(jpg|png|svg)$/, use: 'file-loader'}
]
},
};
答案 0 :(得分:0)
npm模块jsdom
可用于在非浏览器环境中提供窗口和文档。