Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add publicPath to build-javascript and build-html #393

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/utils/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const debug = require('debug')('gatsby:webpack-config')
import path from 'path'
import _ from 'lodash'
import invariant from 'invariant'
import { siteConfig } from 'config'

import babelConfig from './babel-config'

Expand All @@ -30,6 +31,10 @@ try {
module.exports = (program, directory, suppliedStage, webpackPort = 1500, routes = []) => {
const babelStage = suppliedStage
const stage = (suppliedStage === 'develop-html') ? 'develop' : suppliedStage
const linkPrefix = siteConfig.linkPrefix ? siteConfig.linkPrefix : '/'
const publicPath = linkPrefix.indexOf('/') === linkPrefix.length - 1
? linkPrefix
: `${linkPrefix}/`

debug(`Loading webpack config for stage "${stage}"`)
function output () {
Expand All @@ -46,7 +51,7 @@ module.exports = (program, directory, suppliedStage, webpackPort = 1500, routes
return {
path: `${directory}/public`,
filename: 'bundle-for-css.js',
publicPath: '/',
publicPath,
}
case 'build-html':
// A temp file required by static-site-generator-plugin. See plugins() below.
Expand All @@ -55,11 +60,13 @@ module.exports = (program, directory, suppliedStage, webpackPort = 1500, routes
path: `${directory}/public`,
filename: 'render-page.js',
libraryTarget: 'umd',
publicPath,
}
case 'build-javascript':
return {
filename: 'bundle.js',
path: `${directory}/public`,
publicPath,
}
default:
throw new Error(`The state requested ${stage} doesn't exist.`)
Expand Down