Skip to content

Commit

Permalink
Cleaner separation of mock data for webdebugger + easier dev setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Wermke committed May 17, 2016
1 parent 952c830 commit feac1d5
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 86 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build/*.map
node_modules/
npm-debug.log
1 change: 1 addition & 0 deletions webdebugger/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build/*.map
node_modules/
npm-debug.log
79 changes: 40 additions & 39 deletions webdebugger/build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,52 @@ <h1>PostCSS Debugger</h1>

<script>
window.postcssDebug = {
files: [
files: [
{
path: '/Users/andy/workspace/postcss-debug/test/css/test.css',
// maybe `error` object in here (message + stack trace) (snapshot will also be there in `snapshots`)
snapshots: [
{
path: '/Users/andy/workspace/postcss-debug/test/css/test.css',
// maybe `error` object in here (message + stack trace) (snapshot will also be there in `snapshots`)
snapshots: [
{
timestamp: 1462203864674,
prevPlugin: null,
nextPlugin: 'postcss-calc',
content: `
.test {
color: black;
&:hover {
margin-top: calc(10px + 20px)
}
}`
},
{
timestamp: 1462203864674,
prevPlugin: 'postcss-calc',
nextPlugin: 'postcss-nested',
content: `
.test {
color: black;
&:hover {
margin-top: 30px
}
}`
},
{
timestamp: 1462203864674,
prevPlugin: 'postcss-nested',
nextPlugin: null,
content: `
.test {
color: black
timestamp: 1462203864674,
prevPlugin: null,
nextPlugin: 'postcss-calc',
content: `
.test {
color: black;
&:hover {
margin-top: calc(10px + 20px)
}
.test:hover {
}`
},
{
timestamp: 1462203864674,
prevPlugin: 'postcss-calc',
nextPlugin: 'postcss-nested',
content: `
.test {
color: black;
&:hover {
margin-top: 30px
}`
}
]
}
}`
},
{
timestamp: 1462203864674,
prevPlugin: 'postcss-nested',
nextPlugin: null,
content: `
.test {
color: black
}
.test:hover {
margin-top: 30px
}`
}
]
}
]
}

</script>
<script src="./app.js"></script>
</body>
Expand Down
8 changes: 8 additions & 0 deletions webdebugger/dev/prepare-index-html.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict'

var fs = require('fs')

var html = fs.readFileSync(__dirname + '/../src/index.html', { encoding: 'utf8' })
var sampleData = fs.readFileSync(__dirname + '/sample-data.js', { encoding: 'utf8' })

fs.writeFileSync(__dirname + '/../build/index.html', html.replace('/* DEBUG_SNAPSHOTS */', sampleData))
46 changes: 46 additions & 0 deletions webdebugger/dev/sample-data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
files: [
{
path: '/Users/andy/workspace/postcss-debug/test/css/test.css',
// maybe `error` object in here (message + stack trace) (snapshot will also be there in `snapshots`)
snapshots: [
{
timestamp: 1462203864674,
prevPlugin: null,
nextPlugin: 'postcss-calc',
content: `
.test {
color: black;
&:hover {
margin-top: calc(10px + 20px)
}
}`
},
{
timestamp: 1462203864674,
prevPlugin: 'postcss-calc',
nextPlugin: 'postcss-nested',
content: `
.test {
color: black;
&:hover {
margin-top: 30px
}
}`
},
{
timestamp: 1462203864674,
prevPlugin: 'postcss-nested',
nextPlugin: null,
content: `
.test {
color: black
}
.test:hover {
margin-top: 30px
}`
}
]
}
]
}
6 changes: 5 additions & 1 deletion webdebugger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"private": true,
"license": "MIT",
"scripts": {
"build": "rollup -c --sourcemap && cp src/index.html build/",
"build": "rollup -c --sourcemap",
"serve": "node dev/prepare-index-html.js && http-server build/ -o -c-1",
"start": "run-p watch serve",
"watch": "watch 'npm run build' src/"
},
"devDependencies": {
Expand All @@ -13,6 +15,8 @@
"babel-preset-es2015-loose": "^7.0.0",
"babelify": "^7.3.0",
"browserify": "^13.0.0",
"http-server": "^0.9.0",
"npm-run-all": "^2.1.0",
"rollup": "^0.26.2",
"rollup-plugin-babel": "^2.4.0",
"rollup-plugin-commonjs": "^2.2.1",
Expand Down
47 changes: 1 addition & 46 deletions webdebugger/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,52 +17,7 @@ <h1>PostCSS Debugger</h1>
</footer>

<script>
window.postcssDebug = {
files: [
{
path: '/Users/andy/workspace/postcss-debug/test/css/test.css',
// maybe `error` object in here (message + stack trace) (snapshot will also be there in `snapshots`)
snapshots: [
{
timestamp: 1462203864674,
prevPlugin: null,
nextPlugin: 'postcss-calc',
content: `
.test {
color: black;
&:hover {
margin-top: calc(10px + 20px)
}
}`
},
{
timestamp: 1462203864674,
prevPlugin: 'postcss-calc',
nextPlugin: 'postcss-nested',
content: `
.test {
color: black;
&:hover {
margin-top: 30px
}
}`
},
{
timestamp: 1462203864674,
prevPlugin: 'postcss-nested',
nextPlugin: null,
content: `
.test {
color: black
}
.test:hover {
margin-top: 30px
}`
}
]
}
]
}
window.postcssDebug = /* DEBUG_SNAPSHOTS */
</script>
<script src="./app.js"></script>
</body>
Expand Down

0 comments on commit feac1d5

Please sign in to comment.