vigetlabs / blendid

A delicious blend of gulp tasks combined into a configurable asset pipeline and static site builder
MIT License
4.97k stars 680 forks source link

Webpack publicPath & CDN #318

Closed hellojere closed 7 years ago

hellojere commented 8 years ago

I'm using this starter only for coding the CSS & JS for a website hosted elsewhere, so this only acts as a CDN. Everything else is running fine, but not all the scripts are executing as they're supposed to.

I guess it's the Webpack, so what's the ideal way of setting the publicPath for Webpack when generating production builds? I'm talking about the #4 on this article.

Tried setting this to config.json tasks.js.dest as that's again called on the wepback-multi-config.js but that didn't result to anything I expected.

Any help?

greypants commented 8 years ago

Somewhere in this block: https://github.com/vigetlabs/gulp-starter/blob/master/gulpfile.js/lib/webpack-multi-config.js#L73-L87

Add:

webpackConfig.output= 'your/production/public/path'

I think that's what you're looking for.

craigmdennis commented 8 years ago

I just had a similar experience where Webpack wasn't finding the script that I was using as the publicPath (the URI rendered on the page) was different to the path (the actual location of the stored file).

I edited https://github.com/vigetlabs/gulp-starter/blob/master/gulpfile.js/lib/webpack-multi-config.js#L12 as follows:

var publicPath = pathToUrl(config.root.publicPath, config.tasks.js.dest, '/')

and added an additional configuration key in config.json

"publicPath": "./path/rendered/on/page"

Not sure if this will help with a CDN. This also helped: http://stackoverflow.com/questions/28846814/what-does-publicpath-in-webpack-do