Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Updating build steps (CSS) #67

Merged
merged 9 commits into from Feb 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions CONTRIBUTING.md
Expand Up @@ -16,10 +16,15 @@ Setup your system. Change to the cloned folder and type:
$ npm install
```

Make your change. Make sure the tests pass and the CSS for production is built:
Make your changes. To automatically watch for changes, run:
```console
$ npm run dev
```

Make sure the tests pass and the CSS for production is built:

```console
$ grunt
$ npm run build
```

Please add specific topics into a single commit and also take into account the [Wikimedia commit message guidelines](https://www.mediawiki.org/wiki/Gerrit/Commit_message_guidelines).
Expand Down
85 changes: 45 additions & 40 deletions Gruntfile.js
Expand Up @@ -3,13 +3,36 @@
*/

module.exports = function ( grunt ) {
grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
grunt.loadNpmTasks( 'grunt-contrib-watch' );
grunt.loadNpmTasks( 'grunt-postcss' );
grunt.loadNpmTasks( 'grunt-sketch' );
grunt.loadNpmTasks( 'grunt-stylelint' );
grunt.loadNpmTasks( 'grunt-svgmin' );

// PostCSS processors without minifier
var postCssProcessorsDev = [
require( 'postcss-import' )( {
from: "css/wmui-style-guide.dev.css"
} ),
require( 'postcss-custom-properties' ),
require( 'autoprefixer' )( {
browsers: [
"Android >= 2.3",
"Chrome >= 10",
"Edge >= 12",
"Firefox >= 3.6",
"IE >= 8",
"IE_mob 11",
"iOS >= 5.1",
"Opera >= 12.5",
"Safari >= 5.1"
]
} )
];

// PostCSS processors with minifier
var postCssProcessorsMin = postCssProcessorsDev.concat( [ require( 'cssnano' )() ] );

grunt.initConfig( {
// Lint – Styles
stylelint: {
Expand All @@ -22,44 +45,25 @@ module.exports = function ( grunt ) {

// Postprocessing Styles
postcss: {
options: {
processors: [
require( 'postcss-import' )( {
from: "css/wmui-style-guide.dev.css"
} ),
// require( 'postcss-cssnext' )(),
require( 'postcss-custom-properties' ),
require( 'autoprefixer' )( {
browsers: [
"Android >= 2.3",
"Chrome >= 10",
"Edge >= 12",
"Firefox >= 3.6",
"IE >= 8",
"IE_mob 11",
"iOS >= 5.1",
"Opera >= 12.5",
"Safari >= 5.1"
]
} )
]
},
dist: {
files: {
'css/build/wmui-style-guide.css': 'css/wmui-style-guide.dev.css'
}
}
},

cssmin: {
options: {
shorthandCompacting: true,
roundingPrecision: -1
// Output unminified compiled CSS file into `build` dir
dev: {
options: {
processors: postCssProcessorsDev
},
src: 'css/wmui-style-guide.dev.css',
dest: 'css/build/wmui-style-guide.css'
},
target: {
files: {
'css/build/wmui-style-guide.min.css': 'css/build/wmui-style-guide.css'
}
// Output minified compiled CSS file + src maps into `build` dir
min: {
options: {
map: {
inline: false, // save all sourcemaps as separate files...
annotation: 'css/build/' // ...to the specified directory
},
processors: postCssProcessorsMin
},
src: 'css/wmui-style-guide.dev.css',
dest: 'css/build/wmui-style-guide.min.css'
}
},

Expand Down Expand Up @@ -266,7 +270,8 @@ module.exports = function ( grunt ) {
// Development
watch: {
files: [
'**/*.css',
'css/**/*.css',
'!css/build/**/*.css',
'.{stylelintrc}'
],
tasks: 'default'
Expand All @@ -275,5 +280,5 @@ module.exports = function ( grunt ) {

grunt.registerTask( 'lint', [ 'stylelint' ] );
grunt.registerTask( 'imagery', [ 'sketch_export', 'svgmin' ] );
grunt.registerTask( 'default', [ 'lint', 'postcss', 'cssmin' ] );
grunt.registerTask( 'default', [ 'lint', 'postcss:dev', 'postcss:min' ] );
};