Skip to content

Commit bf17ef5

Browse files
author
Brian Muenzenmeyer
committed
Merge pull request #237 from pattern-lab/core-restructure-start
Created /core/ and moved styleguide
2 parents 2a449d2 + 1e21f59 commit bf17ef5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1050
-3671
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ public/styleguide/css/static.css.map
1818
public/styleguide/css/styleguide-specific.css.map
1919
public/styleguide/css/styleguide.css.map
2020
source/css/style.css.map
21+
.idea/
22+
public/styleguide/

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ PL-node-v1.1.0
1111
- THX: Thanks @robinsonaaron for the issue and pull request!
1212
- FIX: Prefer exact pattern key match over fuzzy matches inside getpatternbykey()
1313
- THX: Thanks @EvanLovely for the suggestion
14+
- ADD: Make all paths configurable
15+
- THX: HUGE Thanks to @geoffp and @EvanLovely for their thoughts, time, and talent to make this a reality!
1416
- FIX: Fix issue where absolute paths in the config path object would not resolve
1517
- THX: Thanks to @geoffp and @EvanLovely for reporting, fixing and testing the issue in the dev branch.
1618
- FIX: Typo in gulp instructions in README.
1719
- THX: Thanks @simonknittel for the watchful eyes
20+
- CHG: Changed locations of ./public/styleguide to ./core/styleguide to make ./public/ a cleaner distribution directory
21+
- CHG: Removed scss files and config from project. This is in preparation for including the default asset repo in the future
1822

1923
PL-node-v1.0.0
2024
- FIX: Resolve issue with not hiding underscored patterns.

Gruntfile.js

Lines changed: 28 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module.exports = function(grunt) {
22

3+
var path = require('path');
4+
35
// Project configuration.
46
grunt.initConfig({
57
pkg: grunt.file.readJSON('package.json'),
@@ -60,97 +62,75 @@ module.exports = function(grunt) {
6062
copy: {
6163
main: {
6264
files: [
63-
{ expand: true, cwd: './source/js/', src: '*', dest: './public/js/'},
64-
{ expand: true, cwd: './source/css/', src: '*.css', dest: './public/css/' },
65-
{ expand: true, cwd: './source/images/', src: ['*.png', '*.jpg', '*.gif', '*.jpeg'], dest: './public/images/' },
66-
{ expand: true, cwd: './source/images/sample/', src: ['*.png', '*.jpg', '*.gif', '*.jpeg'], dest: './public/images/sample/'},
67-
{ expand: true, cwd: './source/fonts/', src: '*', dest: './public/fonts/'},
68-
{ expand: true, cwd: './source/_data/', src: 'annotations.js', dest: './public/data/' }
65+
{ expand: true, cwd: paths().source.js, src: '*.js', dest: paths().public.js},
66+
{ expand: true, cwd: paths().source.css, src: '*.css', dest: paths().public.css },
67+
{ expand: true, cwd: paths().source.images, src: ['**/*.png', '**/*.jpg', '**/*.gif', '**/*.jpeg'], dest: paths().public.images },
68+
{ expand: true, cwd: paths().source.fonts, src: '*', dest: paths().public.fonts},
69+
{ expand: true, cwd: paths().source.data, src: 'annotations.js', dest: paths().public.data}
6970
]
7071
},
71-
css: {
72+
styleguide: {
7273
files: [
73-
{ expand: true, cwd: './source/css/', src: '*.css', dest: './public/css/' }
74+
{ expand: true, cwd: paths().source.styleguide, src: ['*.*', '**/*.*'], dest: paths().public.styleguide }
7475
]
7576
}
7677
},
7778
watch: {
7879
all: {
7980
files: [
80-
'source/css/**/*.css',
81-
'public/styleguide/css/*.css',
82-
'source/_patterns/**/*.mustache',
83-
'source/_patterns/**/*.json',
84-
'source/_data/*.json'
81+
paths().source.css + '**/*.css',
82+
paths().source.styleguide + 'css/*.css',
83+
paths().source.patterns + '**/*.mustache',
84+
paths().source.patterns + '**/*.json',
85+
paths().source.data + '*.json'
8586
],
86-
tasks: ['default']
87-
},
88-
// scss: {
89-
// files: ['source/css/**/*.scss', 'public/styleguide/css/*.scss'],
90-
// tasks: ['sass', 'copy:css','bsReload:css']
91-
// },
92-
patterns: {
93-
files: [
94-
'source/_patterns/**/*.mustache',
95-
'source/_patterns/**/*.json',
96-
'source/_data/*.json'
97-
],
98-
tasks: ['default']
87+
tasks: ['default', 'bsReload:css']
9988
}
10089
},
101-
// sass: {
102-
// build: {
103-
// options: {
104-
// style: 'expanded',
105-
// precision: 8
106-
// },
107-
// files: {
108-
// './source/css/style.css': './source/css/style.scss',
109-
// './public/styleguide/css/static.css': './public/styleguide/css/static.scss',
110-
// './public/styleguide/css/styleguide.css': './public/styleguide/css/styleguide.scss',
111-
// './public/styleguide/css/styleguide-specific.css': './public/styleguide/css/styleguide-specific.scss'
112-
// }
113-
// }
114-
// },
11590
nodeunit: {
11691
all: ['test/*_tests.js']
11792
},
11893
browserSync: {
11994
dev: {
12095
options: {
121-
server: './public',
96+
server: paths().public.root,
12297
watchTask: true,
98+
watchOptions: {
99+
ignoreInitial: true,
100+
ignored: '*.html'
101+
},
123102
plugins: [
124103
{
125104
module: 'bs-html-injector',
126105
options: {
127-
files: './public/index.html'
106+
files: [paths().public.root + '/index.html', paths().public.styleguide + '/styleguide.html']
128107
}
129108
}
130109
]
131110
}
132111
}
133112
},
134113
bsReload: {
135-
css: './public/**/*.css'
114+
css: paths().public.root + '**/*.css'
136115
}
137116
});
138117

118+
function paths () {
119+
return require('./config.json').paths;
120+
}
121+
139122
// load all grunt tasks
140123
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
141124

142125
//load the patternlab task
143126
grunt.task.loadTasks('./builder/');
144127

145-
//if you choose to use scss, or any preprocessor, you can add it here
146-
grunt.registerTask('default', ['patternlab', /*'sass',*/ 'copy:main']);
128+
grunt.registerTask('default', ['patternlab', 'copy:main', 'copy:styleguide']);
147129

148130
//travis CI task
149131
grunt.registerTask('travis', ['nodeunit', 'patternlab']);
150132

151-
//TODO: this line is more efficient, but you cannot run concurrent watch tasks without another dependency.
152-
//grunt.registerTask('serve', ['patternlab', /*'sass',*/ 'copy:main', 'browserSync', 'watch:patterns', 'watch:scss']);
153-
grunt.registerTask('serve', ['patternlab', /*'sass',*/ 'copy:main', 'browserSync', 'watch:all']);
133+
grunt.registerTask('serve', ['patternlab', 'copy:main', 'copy:styleguide', 'browserSync', 'watch:all']);
154134

155135
grunt.registerTask('build', ['nodeunit', 'concat']);
156136

README.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,36 @@ Get more information about patternlab-node, pattern lab in general, and where to
8080
##### Watching Changes
8181
To have patternlab-node watch for changes to either a mustache template, data, or stylesheets, run `grunt|gulp watch` or `grunt|gulp serve`. The `Gruntfile|Gulpfile` governs what is watched. It should be easy to add scss or whatever preprocessor you fancy.
8282

83-
##### Preprocessor Support
84-
The patternlab-node release package ships with some `.scss` files utilized in the creation of the style guide and sample templates, but these are not required. The compilation tasks are commented out in the `Gruntfiles|Gulpfiles` but can be uncommented or changed to meet your needs. Sass modules are not included in `package.json` files - the prevailing thought being if you are familiar enough with preprocessors, you can use the instructions for [grunt-contrib-sass](https://github.com/gruntjs/grunt-contrib-sass) / [gulp-sass](https://github.com/dlmanning/gulp-sass) / _preprocessor of choice_ to install them. Uncomment the preprocessor configuration to fully utilize the example templates, css and style guide.
83+
##### Configurable Paths
84+
Pattern Lab Node ships with a particular source and public workflow intended to separate the code you work on with the code generated for consumption elsewhere. If you wish to change any paths, you may do so within `config.json`. The contents are here:
8585

86-
**NOTE:** You may run into issues installing gulp-sass if you don't have the latest Visual Studio on Windows. See [here](https://github.com/sass/node-sass/issues/469) for more information and [this query](https://github.com/sass/node-sass/issues?utf8=%E2%9C%93&q=is%3Aissue+install) for a slew of installation problems related to gulp-sass.
86+
```
87+
"paths" : {
88+
"source" : {
89+
"root": "./source/",
90+
"patterns" : "./source/_patterns/",
91+
"data" : "./source/_data/",
92+
"styleguide" : "./core/styleguide/",
93+
"patternlabFiles" : "./source/_patternlab-files/",
94+
"js" : "./source/js",
95+
"images" : "./source/images",
96+
"fonts" : "./source/fonts",
97+
"css" : "./source/css/"
98+
},
99+
"public" : {
100+
"root" : "./public/",
101+
"patterns" : "./public/patterns/",
102+
"data" : "./public/data/",
103+
"styleguide" : "./public/styleguide/",
104+
"js" : "./public/js",
105+
"images" : "./public/images",
106+
"fonts" : "./public/fonts",
107+
"css" : "./public/css"
108+
}
109+
}
110+
```
111+
112+
Note the intentional repitition of the nested structure, made this way for maximum flexibility. Relative paths are default but absolute paths should work too. You may also use these paths within Grunt or Gulp files by referring to the paths() object.
87113

88114
##### Nav Bar Controls
89115
If you don't have a need for some of the nav-bar tools in the Pattern Lab frontend, you can turn them off in `config.json`.

config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"root": "./source/",
55
"patterns" : "./source/_patterns/",
66
"data" : "./source/_data/",
7+
"styleguide" : "./core/styleguide/",
78
"patternlabFiles" : "./source/_patternlab-files/",
89
"js" : "./source/js",
910
"images" : "./source/images",

0 commit comments

Comments
 (0)