diff --git a/.eslintrc b/.eslintrc index a4e54f109d..99b5d648f3 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,12 +9,5 @@ "no-confusing-arrow": 0, "react/sort-comp": 1, "valid-jsdoc": 0 - }, - "globals": { - "__DEV__": false, - "__DEBUG__": false, - "__STAGING__": false, - "__TEST__": false, - "__PROD__": false } } diff --git a/build/webpack.config.js b/build/webpack.config.js index 5b8d7aa3fc..5f63078db1 100644 --- a/build/webpack.config.js +++ b/build/webpack.config.js @@ -4,7 +4,7 @@ import HtmlWebpackPlugin from 'html-webpack-plugin' import _ from 'lodash' const { paths } = config -const { __DEV__, __TEST__ } = config.compiler_globals +const { __BASE__, __DEV__, __TEST__ } = config.compiler_globals const webpackConfig = { name: 'client', @@ -73,7 +73,8 @@ webpackConfig.plugins = [ 'window.jQuery': 'jquery', }), new HtmlWebpackPlugin({ - template: paths.docsSrc('index.html'), + template: paths.docsSrc('index.ejs'), + baseHref: __BASE__, hash: false, filename: 'index.html', inject: 'body', diff --git a/config/_default.js b/config/_default.js index 89253cef6a..87052ef6f9 100644 --- a/config/_default.js +++ b/config/_default.js @@ -6,6 +6,7 @@ const __DEV__ = env === 'development' const __STAGING__ = env === 'staging' const __TEST__ = env === 'test' const __PROD__ = env === 'production' +const __BASE__ = '/' let config = { env, @@ -57,7 +58,7 @@ config = { compiler_lint: argv.lint !== false, compiler_quiet: false, compiler_output_path: paths.base(config.dir_docs_dist), - compiler_public_path: '/', + compiler_public_path: __BASE__, compiler_vendor: [ 'bluebird', 'classnames', @@ -93,6 +94,7 @@ config = { NODE_ENV: JSON.stringify(env), }, }, + __BASE__: JSON.stringify(__BASE__), __DEV__, __DEBUG__: !!argv.debug, __STAGING__, diff --git a/config/development.js b/config/development.js index 50b5e319b4..20d34319cd 100644 --- a/config/development.js +++ b/config/development.js @@ -1,7 +1,14 @@ -export default (config) => ({ - compiler_devtool: 'source-map', - +export default (config) => { // We use an explicit public path in development to resolve this issue: // http://stackoverflow.com/questions/34133808/webpack-ots-parsing-error-loading-fonts/34133809#34133809 - compiler_public_path: `http://${config.server_host}:${config.server_port}/`, -}) + const __BASE__ = `http://${config.server_host}:${config.server_port}/` + + return { + compiler_devtool: 'source-map', + compiler_public_path: __BASE__, + compiler_globals: { + ...config.compiler_globals, + __BASE__: JSON.stringify(__BASE__), + }, + } +} diff --git a/config/production.js b/config/production.js index 7612aa2ca2..644feba7d8 100644 --- a/config/production.js +++ b/config/production.js @@ -1,11 +1,12 @@ -export default () => ({ +const __BASE__ = '/stardust/' + +export default (config) => ({ compiler_fail_on_warning: true, compiler_hash_type: 'chunkhash', compiler_devtool: false, - // html-webpack-plugin will insert assets into the index.html based on public path - // this needs to be relative on gh-pages otherwise assets try to serve from - // technologyadvice.github.io/ - // ...instead of - // technologyadvice.github.io/stardust - compiler_public_path: '', + compiler_public_path: __BASE__, + compiler_globals: { + ...config.compiler_globals, + __BASE__: JSON.stringify(__BASE__), + }, }) diff --git a/docs/.eslintrc b/docs/.eslintrc new file mode 100644 index 0000000000..62e32c33e2 --- /dev/null +++ b/docs/.eslintrc @@ -0,0 +1,10 @@ +{ + "globals": { + "__BASE__": false, + "__DEV__": false, + "__DEBUG__": false, + "__STAGING__": false, + "__TEST__": false, + "__PROD__": false + } +} diff --git a/docs/app/404.html b/docs/app/404.html index 5be87dbc1e..fc1d72fe6b 100644 --- a/docs/app/404.html +++ b/docs/app/404.html @@ -3,9 +3,7 @@
- +