我有一些static-site-generator-webpack-plugin的问题。Webpack 2:static-site-generator-plugin“self is not defined”
在我的项目我使用:
- 的WebPack V2.1.0-beta.27
- 静态站点发电机的WebPack-插件 V3.1.0
- 反应和react-dom v15.4.1
这是一个单一的网页。
这里是webpack.config.babel.js
文件的一部分:
import StaticSiteGeneratorPlugin from 'static-site-generator-webpack-plugin'
export default {
entry: {
main: './components/Root/index.jsx',
},
output: {
path: path.join(process.cwd(), './public'),
filename: '[name].[hash].js',
libraryTarget: 'umd',
},
plugins: [
// ...
new StaticSiteGeneratorPlugin('main', '/', {}),
]
// ...
}
这是./components/Root/index.jsx
文件:
import React from 'react'
import ReactDOMServer from 'react-dom/server'
import HTMLDocument from 'react-html-document'
import App from '../App/index.jsx'
export default function (locals, callback) {
const MyHtml = (
<HTMLDocument
title='My Page'
metatags={[
{ name: 'description', content: 'My description' },
]}
scripts={[ `${locals.assets.main}` ]}>
<App />
</HTMLDocument>
)
const html = ReactDOMServer.renderToStaticMarkup(MyHtml, locals.assets)
callback(null, '<!doctype html>' + html)
}
当我尝试使用它时,我看到错误消息:ERROR in ReferenceError: self is not defined
。这是什么意思?
friggin'inline:false'属性解决了它。不敢相信。你应该得到一个饼干。 – Birowsky