forked from Tripwire/octagon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstyleguide.config.js
85 lines (79 loc) · 2.2 KB
/
styleguide.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
'use strict'
const path = require('path')
const cssnext = require('postcss-cssnext')
const autoprefixer = require('autoprefixer')
const impy = require('postcss-import')
const neat = require('postcss-neat')
const rucksack = require('rucksack-css')
const glob = require('glob')
const fs = require('fs')
const builder = require('./scripts/builder')
const suirExamples = glob.sync(`${__dirname}/src/components/suir/**/*.examples.md`)
var semanticCSSStat = fs.lstatSync(builder.semanticCSSFilename)
if (!semanticCSSStat.isFile) throw new Error('semantic css file invalid')
const PATHS = {
app: './src/index.js',
dist: path.join(__dirname, 'dist'),
html: './src/index.html'
}
module.exports = {
title: 'Octagon Style Guide',
sections: [
{ name: 'Octagon Native', components: './src/**/*.jsx' },
{
name: 'SUIR Native',
sections: suirExamples.map(ex => ({
name: path.basename(ex).replace(/\.examples\.md/g, ''),
content: ex
}))
}
],
getExampleFilename (componentpath) {
return componentpath.replace(/\.jsx?$/, '.examples.md')
},
getComponentPathLine (componentPath) {
const name = path.basename(componentPath, '.jsx')
return 'import ' + name + ' from ../src/components/' + name + ''
},
skipComponentsWithoutExample: true,
webpackConfig: {
output: {
path: PATHS.dist,
publicPath: '/',
filename: 'bundle.js'
},
devtool: 'eval',
module: {
preLoaders: [
{
test: /\.(js|jsx)$/,
loaders: ['babel-loader'],
exclude: /node_modules/
}
],
loaders: [
{
test: /\.(jpe?g|png|gif|svg)$/i,
loader: 'file-loader?name=[name].[ext]'
},
{
test: /\.css?$/,
loaders: ['style-loader', 'css-loader?importLoaders=1', 'postcss-loader']
},
{
test: /\.(ttf|otf|eot|woff(2)?)(\?[a-z0-9]+)?$/,
loader: 'file-loader?name=fonts/[name].[ext]'
}
]
},
resolve: {
extensions: ['', '.js', '.jsx']
},
postcss: function () {
return {
defaults: [impy, cssnext, neat, rucksack],
cleaner: [autoprefixer({ browsers: ['last 2 version'] })]
}
}
}
}