首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在我的项目中添加了‘static-site-generator- adding plugin’后的问题

在我的项目中添加了‘static-site-generator- adding plugin’后的问题
EN

Stack Overflow用户
提问于 2018-07-19 15:46:05
回答 1查看 536关注 0票数 0

我刚刚在我的项目中添加了'static-site-generator-webpack-plugin‘,我遇到了以下错误:

代码语言:javascript
复制
ERROR in ReferenceError: window is not defined
    at main:1:224
    at ContextifyScript.Script.runInContext (vm.js:59:29)
    at ContextifyScript.Script.runInNewContext (vm.js:65:15)
    at module.exports (/Users/johnnynolan/Repos/css-modules/node_modules/eval/eval.js:69:12)
    at /Users/johnnynolan/Repos/css-modules/node_modules/static-site-generator-webpack-plugin/index.js:42:22
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/johnnynolan/Repos/css-modules/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:7:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (/Users/johnnynolan/Repos/css-modules/node_modules/tapable/lib/Hook.js:35:21)
    at hooks.optimizeChunkAssets.callAsync.err (/Users/johnnynolan/Repos/css-modules/node_modules/webpack/lib/Compilation.js:1275:32)
    at _err0 (eval at create (/Users/johnnynolan/Repos/css-modules/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:11:1)
    at /Users/johnnynolan/Repos/css-modules/node_modules/uglifyjs-webpack-plugin/dist/index.js:282:11

我的webpack.config如下:

代码语言:javascript
复制
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin');
var locals = {
  routes: [
     '/',
    '/about'
  ]
};

module.exports = {
  mode: 'production',
  entry:  './src',
  output: {
    path:  path.join(__dirname, 'build'),
    filename: 'bundle.js',
    libraryTarget: 'umd' // this is super important
  },
   module: {
    rules: [
      {
        test: /\.js$/,
        loader: 'babel-loader',
        include: __dirname + '/src',
      },
      {
        test: /\.css$/,
        loader: ExtractTextPlugin.extract('css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]'),
        include: __dirname + '/src'
      }
    ],
  },
  plugins: [
    new StaticSiteGeneratorPlugin('main', locals.routes),
    new ExtractTextPlugin("styles.css")
  ]
};

我不确定这是不是因为我是怎么设置我的webpack.config的,但是我感觉使用‘静态站点生成器-webpack-插件’有问题?

任何帮助都将不胜感激。

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2018-07-19 20:32:41

您是否尝试过将globalObject: 'this'添加到输出中?详细信息here

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51417076

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档