所以我有一个节点/快递应用程序,用于回送由webpack捆绑的bundle.js。
我已经在这个问题上敲了近4个晚上,我不知道了。
我收到Uncaught SyntaxError: Unexpected token <
错误,因为快速静态中间件没有捕获请求并对其进行处理。
webpack.config.js:
output: {
path: BUILD_DIR,
filename: 'bundle.js',
// https://github.com/webpack/webpack-dev-middleware/issues/205
// DO NOT leave publicPath out -- it'll cause errors if we do
publicPath: '/',
},
表达中间件:
var serveStatic = require('serve-static')
app.use(serveStatic(
path.join(__dirname, 'statics'),
))
app.use('/dist', express.static('dist'));
app.use('/statics', express.static('statics'));\
的index.html:
<script src="bundle.js" type="text/javascript"></script>