Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This also adds support for custom PostCSS plugins. mix.options({ postCss: [require('postcss-css-variables')()] });
- Loading branch information
1 parent
2ac86ae
commit fecd1c9
Showing
6 changed files
with
118 additions
and
20 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
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,61 @@ | ||
module.exports = { | ||
/** | ||
* Whether to extract .vue component styles into a dedicated file. | ||
* You may provide a boolean, or a dedicated path to extract to. | ||
* | ||
* @type {Boolean|string} | ||
*/ | ||
extractVueStyles: false, | ||
|
||
|
||
/** | ||
* Determine if CSS url()s should be processed by Webpack. | ||
* | ||
* @type {Boolean} | ||
*/ | ||
processCssUrls: true, | ||
|
||
|
||
/** | ||
* Uglify-specific settings for Webpack. | ||
* | ||
* See: https://github.com/mishoo/UglifyJS2#compressor-options | ||
* | ||
* @type {Object} | ||
*/ | ||
uglify: { | ||
sourceMap: true, | ||
compress: { | ||
warnings: false, | ||
drop_console: true | ||
} | ||
}, | ||
|
||
|
||
/** | ||
* PostCSS plugins to be applied to compiled CSS. | ||
* | ||
* See: https://github.com/postcss/postcss/blob/master/docs/plugins.md | ||
* | ||
* @type {Array} | ||
*/ | ||
postCss: [ | ||
require('autoprefixer') | ||
], | ||
|
||
|
||
/** | ||
* Merge the given options with the current defaults. | ||
* | ||
* @param {object} options | ||
*/ | ||
merge(options) { | ||
let mergeWith = require('lodash').mergeWith; | ||
|
||
mergeWith(this, options, (objValue, srcValue) => { | ||
if (Array.isArray(objValue)) { | ||
return objValue.concat(srcValue); | ||
} | ||
}); | ||
} | ||
}; |
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,49 @@ | ||
import test from 'ava'; | ||
import options from '../src/Options'; | ||
|
||
|
||
test('that it merges options', t => { | ||
t.is(true, options.processCssUrls); | ||
|
||
options.merge({ | ||
processCssUrls: false | ||
}); | ||
|
||
t.is(false, options.processCssUrls); | ||
}); | ||
|
||
|
||
test('that it deeply merges options', t => { | ||
t.deepEqual({ | ||
warnings: false, | ||
drop_console: true | ||
}, options.uglify.compress); | ||
|
||
options.merge({ | ||
uglify: { | ||
compress: { | ||
drop_console: false | ||
} | ||
} | ||
}); | ||
|
||
// It should merge in the drop_console change, without | ||
// affecting any other default props on the object. | ||
t.deepEqual({ | ||
warnings: false, | ||
drop_console: false | ||
}, options.uglify.compress); | ||
}); | ||
|
||
|
||
test('that it appends to default arrays', t => { | ||
options.postCss = ['stub']; | ||
|
||
options.merge({ | ||
postCss: ['some-postcss-plugin'] | ||
}); | ||
|
||
t.deepEqual([ | ||
'stub', 'some-postcss-plugin' | ||
], options.postCss); | ||
}); |