-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from mediamonks/feature/storybook-2
Add Storybook and other updates
- Loading branch information
Showing
79 changed files
with
2,604 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,4 +59,3 @@ node_modules/ | |
### Project | ||
|
||
/dist/ | ||
bundlesize-profile.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { configure } from 'storybook/utils/utils'; | ||
|
||
const context = require.context('app/component/', true, /preset\.js$/); | ||
|
||
function loadStories() { | ||
context.keys().forEach(context); | ||
} | ||
|
||
configure(loadStories); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* Webpack config used during development | ||
*/ | ||
const path = require('path'); | ||
const merge = require('webpack-merge'); | ||
const config = require('../index'); | ||
|
||
const { | ||
getBabelLoaderConfig, | ||
getHbsInlineLoaderConfig, | ||
getESLintLoader, | ||
getTSLintLoader, | ||
getStyleLintPlugin, | ||
} = require('../webpack/webpack-helpers'); | ||
|
||
const projectRoot = path.resolve(__dirname, '../../../'); | ||
const port = process.env.PORT || config.storybook.port; | ||
|
||
module.exports = merge(require('../webpack/webpack.config.base'), { | ||
entry: { | ||
storybook: [ | ||
'./src/app/polyfills.js', | ||
'./src/storybook/storybook.js', | ||
'./build-tools/config/storybook/config.js', | ||
], | ||
story: [ | ||
'./src/app/polyfills.js', | ||
'./src/storybook/story.js', | ||
'./build-tools/config/storybook/config.js', | ||
], | ||
}, | ||
output: { | ||
path: config.storybook.buildPath, | ||
publicPath: config.storybook.publicPath, | ||
}, | ||
resolve: { | ||
extensions: ['.hbs', '.ts', '.js', '.json'], | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /preset\.js$/, | ||
include: [ | ||
/src[\/\\]app/, | ||
], | ||
use: [ | ||
{ | ||
loader :'preset-loader', | ||
options: {}, | ||
}, | ||
getHbsInlineLoaderConfig(), | ||
getBabelLoaderConfig(), | ||
] | ||
}, | ||
getESLintLoader(config.storybook.enableESLintLoader), | ||
getTSLintLoader(config.storybook.enableTSLintLoader), | ||
{ | ||
test: /\.js$/, | ||
enforce: 'pre', | ||
loader: 'source-map-loader' | ||
}, | ||
] | ||
}, | ||
plugins: [ | ||
getStyleLintPlugin(config.storybook.enableStyleLintPlugin), | ||
].filter(_ => _), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* Webpack config used during development | ||
*/ | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
const merge = require('webpack-merge'); | ||
const ExtractTextPlugin = require('extract-text-webpack-plugin'); | ||
const CopyWebpackPlugin = require('copy-webpack-plugin'); | ||
const ImageminPlugin = require('imagemin-webpack-plugin').default; | ||
const imageminMozjpeg = require('imagemin-mozjpeg'); | ||
|
||
const config = require('../index'); | ||
|
||
const { | ||
getStyleRules, | ||
getCodeRules, | ||
getHandlebarsRules, | ||
} = require('../webpack/webpack-helpers'); | ||
|
||
const projectRoot = path.resolve(__dirname, '../../../'); | ||
const port = process.env.PORT || config.storybook.port; | ||
|
||
module.exports = merge(require('./webpack.config.base'), { | ||
output: { | ||
path: config.storybook.buildPath, | ||
publicPath: config.storybook.publicPath, | ||
}, | ||
module: { | ||
rules: [ | ||
...getHandlebarsRules({ development: true }), | ||
...getCodeRules(), | ||
...getStyleRules({ development: false }), | ||
] | ||
}, | ||
plugins: [ | ||
// enable HMR globally | ||
new webpack.HotModuleReplacementPlugin(), | ||
|
||
new webpack.DefinePlugin({ | ||
'process.env': config.dist.env, | ||
}), | ||
|
||
new CopyWebpackPlugin([ | ||
{ | ||
// copy files to public root (not versioned) | ||
context: config.dist.staticPath, | ||
from: '**/*', | ||
to: config.storybook.buildPath, | ||
}, | ||
{ | ||
// copy files to public root (not versioned) | ||
context: config.storybook.staticPath, | ||
from: '**/*', | ||
to: config.storybook.buildPath, | ||
}, | ||
]), | ||
|
||
new ExtractTextPlugin({ | ||
filename: 'asset/[name].css', | ||
allChunks : true, | ||
}), | ||
|
||
new ImageminPlugin({ | ||
disable: !config.dist.enableImageOptimization, | ||
svgo: null, | ||
gifsicle: null, | ||
jpegtran: null, | ||
optipng: !config.dist.enablePNGQuant ? { optimizationLevel: 3 } : null, | ||
pngquant: config.dist.enablePNGQuant ? { quality: '65' } : null, | ||
plugins: [ | ||
imageminMozjpeg({ | ||
quality: 85, | ||
progressive: true | ||
}) | ||
], | ||
}), | ||
].filter(_ => _), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* Webpack config used during development | ||
*/ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
const merge = require('webpack-merge'); | ||
const config = require('../index'); | ||
|
||
const { | ||
getStyleRules, | ||
getCodeRules, | ||
getHandlebarsRules, | ||
} = require('../webpack/webpack-helpers'); | ||
|
||
const projectRoot = path.resolve(__dirname, '../../../'); | ||
const port = process.env.PORT || config.storybook.port; | ||
|
||
module.exports = merge(require('./webpack.config.base'), { | ||
output: { | ||
path: config.storybook.buildPath, | ||
publicPath: config.storybook.publicPath, | ||
}, | ||
plugins: [ | ||
// enable HMR globally | ||
new webpack.HotModuleReplacementPlugin(), | ||
|
||
new webpack.DefinePlugin({ | ||
'process.env': config.dist.env, | ||
}), | ||
].filter(_ => _), | ||
module: { | ||
rules: [ | ||
...getHandlebarsRules({ development: true }), | ||
...getCodeRules(), | ||
...getStyleRules({ development: true }), | ||
] | ||
}, | ||
devServer: { | ||
hotOnly: true, | ||
publicPath: config.storybook.publicPath, | ||
contentBase: config.storybook.staticPath, | ||
compress: true, | ||
host: '0.0.0.0', | ||
port, | ||
disableHostCheck: true, | ||
overlay: true, | ||
noInfo: true, | ||
before(app) { | ||
// render basic default index.html for all html files (path will be picked by JS) | ||
app.use((req, res, next) => { | ||
if (req.path.includes('storybook.html')) { | ||
res.send(fs.readFileSync(path.resolve(projectRoot, 'src/storybook/storybook.html'), 'utf-8')); | ||
} else if (req.path.includes('story.html')) { | ||
res.send(fs.readFileSync(path.resolve(projectRoot, 'src/storybook/story.html'), 'utf-8')); | ||
} else { | ||
next(); | ||
} | ||
}); | ||
|
||
// also render index.html on / | ||
app.get('/', function(req, res) { | ||
res.send(fs.readFileSync(path.resolve(projectRoot, 'src/storybook/storybook.html'), 'utf-8')); | ||
}); | ||
}, | ||
https: (config.useHttps ? { | ||
key: fs.readFileSync(path.resolve(projectRoot, 'build-tools/ssl/key.pem')), | ||
cert: fs.readFileSync(path.resolve(projectRoot, 'build-tools/ssl/cert.pem')), | ||
} : false), | ||
}, | ||
devtool: 'eval-source-map' | ||
}); |
Oops, something went wrong.