Gatsby: 无法设置 webpack output.publicPath

创建于 2019-06-16  ·  1评论  ·  资料来源: gatsbyjs/gatsby

描述

我想在 chrome 开发工具中查看我的 css blob 的文件名。
image
style-loader 自述文件指出必须设置 output.publicPath webpack 属性。 通过 gatsby-config.js 设置它会使gatsby develop失败。

重现步骤

gatsby-node.js:

  exports.onCreateWebpackConfig = ({ stage, rules, loaders, plugins, actions }) => actions.setWebpackConfig({
    output: {
      publicPath: '/',
    },
 });

预期结果

它应该设置路径,并且应该从我配置的样式加载器为我的 css 文件生成绝对路径

实际结果

> gatsby develop

success open and validate gatsby-configs - 0.058 s
success load plugins - 1.072 s
success onPreInit - 0.009 s
success initialize cache - 0.035 s
success copy gatsby files - 0.138 s
success onPreBootstrap - 0.026 s
success source and transform nodes - 0.087 s
success building schema - 0.349 s
success createPages - 0.004 s
success createPagesStatefully - 0.082 s
success onPreExtractQueries - 0.015 s
success update schema - 0.042 s
success extract queries from components - 0.157 s
success run static queries - 0.208 s — 2/2 10.53 queries/second
success run page queries - 0.052 s — 6/6 146.57 queries/second
success write out page data - 0.011 s
success write out redirect data - 0.008 s
success Build manifest and related icons - 0.411 s
success Build manifest and related icons - 0.014 s
success onPostBootstrap - 0.476 s
⠀
info bootstrap finished - 9.560 s
⠀
error There was an error compiling the html.js component for the development server.

See our docs page on debugging HTML builds for help https://gatsby.dev/debug-html


  Error: ./.cache/gatsby-browser-entry.js
  Module not found: Error: Can't resolve 'gatsby-link' in '/.../.cac
  he'
  resolve 'gatsby-link' in '/.../.cache'
    Parsed request is a module
   @ ./.cache/gatsby-browser-entry.js 3:0-112 42:0-45:64 42:0-45:64 42:0-45:64 42:0-45:64 42:0-45:64
  42:0-45:64 42:0-45:64 42:0-45:64
   @ ./node_modules/gatsby-plugin-manifest/gatsby-ssr.js
   @ ./.cache/api-runner-ssr.js

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] develop: `gatsby develop`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] develop script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /.../.npm/_logs/2019-06-16T19_56_49_086Z-debug.log
error Command failed with exit code 1.

环境

系统:
操作系统:macOS High Sierra 10.13.6
CPU:(4) x64 Intel(R) Core(TM) i5-4260U CPU @ 1.40GHz
外壳:5.6.2 - /usr/local/bin/zsh
二进制文件:
节点:10.15.2 - /usr/local/bin/node
纱线:1.13.0 - /usr/local/bin/yarn
npm: 6.7.0 - /usr/local/bin/npm
语言:
Python:2.7.15 - /usr/local/bin/python
浏览器:
铬:74.0.3729.169
Safari:12.1.1
npm 软件包:
盖茨比:^2.8.6 => 2.8.6
盖茨比图像:^2.1.2 => 2.1.2
盖茨比插件清单:^2.1.1 => 2.1.1
盖茨比插件离线:^2.1.1 => 2.1.1
盖茨比插件反应头盔:^3.0.12 => 3.0.12
gatsby-plugin-sass: ^2.0.11 => 2.0.11
gatsby-plugin-sharp: ^2.1.3 => 2.1.3
盖茨比插件打字稿:^2.0.15 => 2.0.15
gatsby 源文件系统:^2.0.38 => 2.0.38
盖茨比变压器夏普:^2.1.21 => 2.1.21

question or discussion

>所有评论

@wildeyes

如果设置,一些配置选项将被忽略,以防止意外损坏。 具体来说,对 entry、output、target 或 resolveLoaders 的任何更改都将被忽略。

正如https://www.gatsbyjs.org/docs/actions/#setWebpackConfig (上面摘录)中所述,我们不支持设置几个键, output就是其中之一!

暂时关闭此问题,但如果我们可以帮助解决与此相关的任何其他问题,请随时重新打开。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

theduke picture theduke  ·  3评论

kalinchernev picture kalinchernev  ·  3评论

3CordGuy picture 3CordGuy  ·  3评论

andykais picture andykais  ·  3评论

dustinhorton picture dustinhorton  ·  3评论