mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-06 07:21:16 +08:00
Update dist
This commit is contained in:
parent
53df979d8a
commit
9bba63f423
3
dist/client/manager/provider.js
vendored
3
dist/client/manager/provider.js
vendored
@ -57,6 +57,7 @@ var _preview2 = _interopRequireDefault(_preview);
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/* global location */
|
||||
/* eslint class-methods-use-this: 0 */
|
||||
|
||||
var ReactProvider = function (_Provider) {
|
||||
(0, _inherits3.default)(ReactProvider, _Provider);
|
||||
@ -70,7 +71,7 @@ var ReactProvider = function (_Provider) {
|
||||
_this.channel = (0, _storybookChannelPagebus2.default)({ key: _this.dataId });
|
||||
_storybookAddons2.default.setChannel(_this.channel);
|
||||
_this.database = _storybookAddons2.default.getDatabase();
|
||||
if (!_this.database) {
|
||||
if (!_this.database && process.env.STORYBOOK_ENABLE_DB) {
|
||||
var bundled = process.env.NODE_ENV === 'production';
|
||||
if (bundled) {
|
||||
_this.database = (0, _storybookDatabaseLocal2.default)({ url: 'addon-db.json', bundled: bundled });
|
||||
|
9
dist/client/preview/story_store.js
vendored
9
dist/client/preview/story_store.js
vendored
@ -20,6 +20,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
||||
|
||||
var cnt = 0;
|
||||
|
||||
function getId() {
|
||||
cnt += 1;
|
||||
return cnt;
|
||||
}
|
||||
|
||||
var StoryStore = function () {
|
||||
function StoryStore() {
|
||||
(0, _classCallCheck3.default)(this, StoryStore);
|
||||
@ -33,14 +38,14 @@ var StoryStore = function () {
|
||||
if (!this._data[kind]) {
|
||||
this._data[kind] = {
|
||||
kind: kind,
|
||||
index: cnt++,
|
||||
index: getId(),
|
||||
stories: {}
|
||||
};
|
||||
}
|
||||
|
||||
this._data[kind].stories[name] = {
|
||||
name: name,
|
||||
index: cnt++,
|
||||
index: getId(),
|
||||
fn: fn
|
||||
};
|
||||
}
|
||||
|
39
dist/server/build.js
vendored
39
dist/server/build.js
vendored
@ -60,19 +60,32 @@ _commander2.default.version(_package2.default.version).option('-s, --static-dir
|
||||
configDir: 'STORYBOOK_CONFIG_DIR'
|
||||
});
|
||||
|
||||
// Build the webpack configuration using the `baseConfig`
|
||||
// custom `.babelrc` file and `webpack.config.js` files
|
||||
var configDir = _commander2.default.configDir || './.storybook';
|
||||
var config = (0, _config2.default)('PRODUCTION', _webpackConfig2.default, configDir);
|
||||
|
||||
var publicPath = config.output.publicPath;
|
||||
|
||||
var outputDir = _commander2.default.outputDir || './storybook-static';
|
||||
config.output.path = outputDir;
|
||||
|
||||
// create output directory (and the static dir) if not exists
|
||||
_shelljs2.default.rm('-rf', outputDir);
|
||||
_shelljs2.default.mkdir('-p', _path2.default.resolve(outputDir));
|
||||
_shelljs2.default.cp(_path2.default.resolve(__dirname, 'public/favicon.ico'), outputDir);
|
||||
|
||||
// The addon database service is disabled by default for now
|
||||
// It should be enabled with the --enable-db for dev server
|
||||
if (_commander2.default.enableDb) {
|
||||
// NOTE enables database on client
|
||||
process.env.STORYBOOK_ENABLE_DB = 1;
|
||||
var dbPath = _commander2.default.dbPath || _path2.default.resolve(configDir, 'addon-db.json');
|
||||
// create addon-db.json file if it's missing to avoid the 404 error
|
||||
if (!_fs2.default.existsSync(dbPath)) {
|
||||
_fs2.default.writeFileSync(dbPath, '{}');
|
||||
}
|
||||
_shelljs2.default.cp(dbPath, outputDir);
|
||||
}
|
||||
|
||||
// Build the webpack configuration using the `baseConfig`
|
||||
// custom `.babelrc` file and `webpack.config.js` files
|
||||
// NOTE changes to env should be done before calling `getBaseConfig`
|
||||
var config = (0, _config2.default)('PRODUCTION', (0, _webpackConfig2.default)(), configDir);
|
||||
config.output.path = outputDir;
|
||||
|
||||
// copy all static files
|
||||
if (_commander2.default.staticDir) {
|
||||
@ -86,19 +99,9 @@ if (_commander2.default.staticDir) {
|
||||
});
|
||||
}
|
||||
|
||||
// The addon database service is disabled by default for now
|
||||
// It should be enabled with the --enable-db for dev server
|
||||
if (_commander2.default.enableDb) {
|
||||
var dbPath = _commander2.default.dbPath || _path2.default.resolve(configDir, 'addon-db.json');
|
||||
// create addon-db.json file if it's missing to avoid the 404 error
|
||||
if (!_fs2.default.existsSync(dbPath)) {
|
||||
_fs2.default.writeFileSync(dbPath, '{}');
|
||||
}
|
||||
_shelljs2.default.cp(dbPath, outputDir);
|
||||
}
|
||||
|
||||
// Write both the storybook UI and IFRAME HTML files to destination path.
|
||||
var headHtml = (0, _utils.getHeadHtml)(configDir);
|
||||
var publicPath = config.output.publicPath;
|
||||
_fs2.default.writeFileSync(_path2.default.resolve(outputDir, 'index.html'), (0, _index2.default)(publicPath));
|
||||
_fs2.default.writeFileSync(_path2.default.resolve(outputDir, 'iframe.html'), (0, _iframe2.default)(headHtml, publicPath));
|
||||
|
||||
|
66
dist/server/config/webpack.config.js
vendored
66
dist/server/config/webpack.config.js
vendored
@ -4,6 +4,39 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function () {
|
||||
var config = {
|
||||
devtool: '#cheap-module-eval-source-map',
|
||||
entry: {
|
||||
manager: [require.resolve('./polyfills'), require.resolve('../../client/manager')],
|
||||
preview: [require.resolve('./polyfills'), require.resolve('./error_enhancements'), require.resolve('webpack-hot-middleware/client') + '?reload=true']
|
||||
},
|
||||
output: {
|
||||
path: _path2.default.join(__dirname, 'dist'),
|
||||
filename: 'static/[name].bundle.js',
|
||||
publicPath: '/'
|
||||
},
|
||||
plugins: [new _webpack2.default.DefinePlugin((0, _utils.loadEnv)()), new _utils.OccurenceOrderPlugin(), new _webpack2.default.HotModuleReplacementPlugin(), new _caseSensitivePathsWebpackPlugin2.default(), new _WatchMissingNodeModulesPlugin2.default(_utils.nodeModulesPaths)],
|
||||
module: {
|
||||
loaders: [{
|
||||
test: /\.jsx?$/,
|
||||
loader: require.resolve('babel-loader'),
|
||||
query: _babel2.default,
|
||||
include: _utils.includePaths,
|
||||
exclude: _utils.excludePaths
|
||||
}]
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
// This is to add addon support for NPM2
|
||||
'@kadira/storybook-addons': require.resolve('@kadira/storybook-addons')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return config;
|
||||
};
|
||||
|
||||
var _path = require('path');
|
||||
|
||||
var _path2 = _interopRequireDefault(_path);
|
||||
@ -26,35 +59,4 @@ var _babel = require('./babel.js');
|
||||
|
||||
var _babel2 = _interopRequireDefault(_babel);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var config = {
|
||||
devtool: '#cheap-module-eval-source-map',
|
||||
entry: {
|
||||
manager: [require.resolve('./polyfills'), require.resolve('../../client/manager')],
|
||||
preview: [require.resolve('./polyfills'), require.resolve('./error_enhancements'), require.resolve('webpack-hot-middleware/client') + '?reload=true']
|
||||
},
|
||||
output: {
|
||||
path: _path2.default.join(__dirname, 'dist'),
|
||||
filename: 'static/[name].bundle.js',
|
||||
publicPath: '/'
|
||||
},
|
||||
plugins: [new _webpack2.default.DefinePlugin((0, _utils.loadEnv)()), new _utils.OccurenceOrderPlugin(), new _webpack2.default.HotModuleReplacementPlugin(), new _caseSensitivePathsWebpackPlugin2.default(), new _WatchMissingNodeModulesPlugin2.default(_utils.nodeModulesPaths)],
|
||||
module: {
|
||||
loaders: [{
|
||||
test: /\.jsx?$/,
|
||||
loader: require.resolve('babel-loader'),
|
||||
query: _babel2.default,
|
||||
include: _utils.includePaths,
|
||||
exclude: _utils.excludePaths
|
||||
}]
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
// This is to add addon support for NPM2
|
||||
'@kadira/storybook-addons': require.resolve('@kadira/storybook-addons')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.default = config;
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
116
dist/server/config/webpack.config.prod.js
vendored
116
dist/server/config/webpack.config.prod.js
vendored
@ -4,6 +4,64 @@ Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function () {
|
||||
var entries = {
|
||||
preview: [require.resolve('./polyfills')],
|
||||
manager: [require.resolve('./polyfills'), _path2.default.resolve(__dirname, '../../client/manager')]
|
||||
};
|
||||
|
||||
var config = {
|
||||
bail: true,
|
||||
devtool: '#cheap-module-source-map',
|
||||
entry: entries,
|
||||
output: {
|
||||
filename: 'static/[name].bundle.js',
|
||||
// Here we set the publicPath to ''.
|
||||
// This allows us to deploy storybook into subpaths like GitHub pages.
|
||||
// This works with css and image loaders too.
|
||||
// This is working for storybook since, we don't use pushState urls and
|
||||
// relative URLs works always.
|
||||
publicPath: ''
|
||||
},
|
||||
plugins: [new _webpack2.default.DefinePlugin((0, _utils.loadEnv)({ production: true })), new _webpack2.default.optimize.DedupePlugin(), new _webpack2.default.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
screw_ie8: true,
|
||||
warnings: false
|
||||
},
|
||||
mangle: {
|
||||
screw_ie8: true
|
||||
},
|
||||
output: {
|
||||
comments: false,
|
||||
screw_ie8: true
|
||||
}
|
||||
})],
|
||||
module: {
|
||||
loaders: [{
|
||||
test: /\.jsx?$/,
|
||||
loader: require.resolve('babel-loader'),
|
||||
query: _babelProd2.default,
|
||||
include: _utils.includePaths,
|
||||
exclude: _utils.excludePaths
|
||||
}]
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
// This is to add addon support for NPM2
|
||||
'@kadira/storybook-addons': require.resolve('@kadira/storybook-addons')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Webpack 2 doesn't have a OccurenceOrderPlugin plugin in the production mode.
|
||||
// But webpack 1 has it. That's why we do this.
|
||||
if (_utils.OccurenceOrderPlugin) {
|
||||
config.plugins.unshift(new _utils.OccurenceOrderPlugin());
|
||||
}
|
||||
|
||||
return config;
|
||||
};
|
||||
|
||||
var _path = require('path');
|
||||
|
||||
var _path2 = _interopRequireDefault(_path);
|
||||
@ -18,60 +76,4 @@ var _babelProd = require('./babel.prod.js');
|
||||
|
||||
var _babelProd2 = _interopRequireDefault(_babelProd);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var entries = {
|
||||
preview: [require.resolve('./polyfills')],
|
||||
manager: [require.resolve('./polyfills'), _path2.default.resolve(__dirname, '../../client/manager')]
|
||||
};
|
||||
|
||||
var config = {
|
||||
bail: true,
|
||||
devtool: '#cheap-module-source-map',
|
||||
entry: entries,
|
||||
output: {
|
||||
filename: 'static/[name].bundle.js',
|
||||
// Here we set the publicPath to ''.
|
||||
// This allows us to deploy storybook into subpaths like GitHub pages.
|
||||
// This works with css and image loaders too.
|
||||
// This is working for storybook since, we don't use pushState urls and
|
||||
// relative URLs works always.
|
||||
publicPath: ''
|
||||
},
|
||||
plugins: [new _webpack2.default.DefinePlugin((0, _utils.loadEnv)({ production: true })), new _webpack2.default.optimize.DedupePlugin(), new _webpack2.default.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
screw_ie8: true,
|
||||
warnings: false
|
||||
},
|
||||
mangle: {
|
||||
screw_ie8: true
|
||||
},
|
||||
output: {
|
||||
comments: false,
|
||||
screw_ie8: true
|
||||
}
|
||||
})],
|
||||
module: {
|
||||
loaders: [{
|
||||
test: /\.jsx?$/,
|
||||
loader: require.resolve('babel-loader'),
|
||||
query: _babelProd2.default,
|
||||
include: _utils.includePaths,
|
||||
exclude: _utils.excludePaths
|
||||
}]
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
// This is to add addon support for NPM2
|
||||
'@kadira/storybook-addons': require.resolve('@kadira/storybook-addons')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Webpack 2 doesn't have a OccurenceOrderPlugin plugin in the production mode.
|
||||
// But webpack 1 has it. That's why we do this.
|
||||
if (_utils.OccurenceOrderPlugin) {
|
||||
config.plugins.unshift(new _utils.OccurenceOrderPlugin());
|
||||
}
|
||||
|
||||
exports.default = config;
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
12
dist/server/index.js
vendored
12
dist/server/index.js
vendored
@ -9,6 +9,10 @@ var _express = require('express');
|
||||
|
||||
var _express2 = _interopRequireDefault(_express);
|
||||
|
||||
var _serveFavicon = require('serve-favicon');
|
||||
|
||||
var _serveFavicon2 = _interopRequireDefault(_serveFavicon);
|
||||
|
||||
var _commander = require('commander');
|
||||
|
||||
var _commander2 = _interopRequireDefault(_commander);
|
||||
@ -67,6 +71,7 @@ if (_commander2.default.host) {
|
||||
}
|
||||
|
||||
var app = (0, _express2.default)();
|
||||
app.use((0, _serveFavicon2.default)(_path2.default.resolve(__dirname, 'public/favicon.ico')));
|
||||
|
||||
if (_commander2.default.staticDir) {
|
||||
_commander2.default.staticDir = (0, _utils.parseList)(_commander2.default.staticDir);
|
||||
@ -84,15 +89,20 @@ if (_commander2.default.staticDir) {
|
||||
// Build the webpack configuration using the `baseConfig`
|
||||
// custom `.babelrc` file and `webpack.config.js` files
|
||||
var configDir = _commander2.default.configDir || './.storybook';
|
||||
app.use((0, _middleware4.default)(configDir));
|
||||
|
||||
// The addon database service is disabled by default for now
|
||||
// It should be enabled with the --enable-db for dev server
|
||||
if (_commander2.default.enableDb) {
|
||||
// NOTE enables database on client
|
||||
process.env.STORYBOOK_ENABLE_DB = 1;
|
||||
var dbPath = _commander2.default.dbPath || _path2.default.resolve(configDir, 'addon-db.json');
|
||||
app.use('/db', (0, _middleware2.default)(dbPath));
|
||||
}
|
||||
|
||||
// NOTE changes to env should be done before calling `getBaseConfig`
|
||||
// `getBaseConfig` function which is called inside the middleware
|
||||
app.use((0, _middleware4.default)(configDir));
|
||||
|
||||
app.listen.apply(app, listenAddr.concat([function (error) {
|
||||
if (error) {
|
||||
throw error;
|
||||
|
4
dist/server/middleware.js
vendored
4
dist/server/middleware.js
vendored
@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
|
||||
exports.default = function (configDir) {
|
||||
// Build the webpack configuration using the `baseConfig`
|
||||
// Build the webpack configuration using the `getBaseConfig`
|
||||
// custom `.babelrc` file and `webpack.config.js` files
|
||||
var config = (0, _config2.default)('DEVELOPMENT', _webpack4.default, configDir);
|
||||
var config = (0, _config2.default)('DEVELOPMENT', (0, _webpack4.default)(), configDir);
|
||||
|
||||
// remove the leading '/'
|
||||
var publicPath = config.output.publicPath;
|
||||
|
Loading…
x
Reference in New Issue
Block a user