mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-20 05:02:37 +08:00
CRA's PUBLIC_URL support (#529)
* Bug fix: Copy static content to the root of the export dir. c * Add support to PUBLIC_URL env variable.
This commit is contained in:
parent
359df9a763
commit
8cc1ff1604
2
dist/server/build.js
vendored
Normal file → Executable file
2
dist/server/build.js
vendored
Normal file → Executable file
@ -95,7 +95,7 @@ if (_commander2.default.staticDir) {
|
||||
process.exit(-1);
|
||||
}
|
||||
logger.log('=> Copying static files from: ' + dir);
|
||||
_shelljs2.default.cp('-r', dir + '/', outputDir);
|
||||
_shelljs2.default.cp('-r', dir + '/*', outputDir);
|
||||
});
|
||||
}
|
||||
|
||||
|
7
dist/server/config/utils.js
vendored
7
dist/server/config/utils.js
vendored
@ -47,7 +47,12 @@ function loadEnv() {
|
||||
|
||||
var defaultNodeEnv = options.production ? 'production' : 'development';
|
||||
var env = {
|
||||
'process.env.NODE_ENV': (0, _stringify2.default)(process.env.NODE_ENV || defaultNodeEnv)
|
||||
'process.env.NODE_ENV': (0, _stringify2.default)(process.env.NODE_ENV || defaultNodeEnv),
|
||||
// This is to support CRA's public folder feature.
|
||||
// In production we set this to dot(.) to allow the browser to access these assests
|
||||
// even when deployed inside a subpath. (like in GitHub pages)
|
||||
// In development this is just empty as we always serves from the root.
|
||||
'process.env.PUBLIC_URL': (0, _stringify2.default)(options.production ? '.' : '')
|
||||
};
|
||||
|
||||
(0, _keys2.default)(process.env).filter(function (name) {
|
||||
|
@ -69,7 +69,7 @@ if (program.staticDir) {
|
||||
process.exit(-1);
|
||||
}
|
||||
logger.log(`=> Copying static files from: ${dir}`);
|
||||
shelljs.cp('-r', `${dir}/`, outputDir);
|
||||
shelljs.cp('-r', `${dir}/*`, outputDir);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,11 @@ export function loadEnv(options = {}) {
|
||||
const defaultNodeEnv = options.production ? 'production' : 'development';
|
||||
const env = {
|
||||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || defaultNodeEnv),
|
||||
// This is to support CRA's public folder feature.
|
||||
// In production we set this to dot(.) to allow the browser to access these assests
|
||||
// even when deployed inside a subpath. (like in GitHub pages)
|
||||
// In development this is just empty as we always serves from the root.
|
||||
'process.env.PUBLIC_URL': JSON.stringify(options.production ? '.' : ''),
|
||||
};
|
||||
|
||||
Object.keys(process.env)
|
||||
|
Loading…
x
Reference in New Issue
Block a user