Skip to content

Commit 9e99e70

Browse files
committed
Example and readme
1 parent e16c8a9 commit 9e99e70

4 files changed

Lines changed: 18 additions & 12 deletions

File tree

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ The build script:
1515
var browserify = require('browserify')
1616
var fs = require('fs')
1717

18-
var to = __dirname + '/static/bundle.js'
1918
var b = browserify(__dirname + '/src/entry.js')
2019
b.transform(require('browserify-postcss', {
2120
// a list of postcss plugins
@@ -24,13 +23,15 @@ b.transform(require('browserify-postcss', {
2423
'postcss-advanced-variables',
2524
['postcss-custom-url', [
2625
['inline', { maxSize: 10 }],
27-
['copy', { assetOutFolder: __dirname + '/static/assets' }],
26+
['copy', {
27+
assetOutFolder: __dirname + '/static/assets',
28+
baseUrl: 'assets',
29+
name: '[name].[hash]',
30+
}],
2831
]],
2932
],
3033
// basedir where to search plugins
3134
basedir: __dirname + '/src',
32-
// options for processing.
33-
postCssOptions: { to: to },
3435
// insert a style element to apply the styles
3536
inject: true,
3637
})
@@ -61,10 +62,15 @@ Default: `null`
6162
Specify where to look for plugins.
6263
6364
### postCssOptions
64-
Specify the options for the [postcss] processor.
65+
Specify the [options](https://github.com/postcss/postcss/blob/master/docs/api.md#processorprocesscss-opts)
66+
for the [postcss] processor.
6567
6668
The `from` and `to` fields will be set to the css file path by default.
6769
70+
The `to` option is used to calculated `url()` in the final styles.
71+
However, if your [postcss] plugin does not need it,
72+
don't bother to specify.
73+
6874
### inject
6975
Specify how to use the styles:
7076

example/build.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ var del = require('del')
66
del.sync(__dirname + '/static/assets')
77
del.sync(__dirname + '/static/bundle.js')
88

9-
var to = __dirname + '/static/bundle.js'
109
var b = browserify(__dirname + '/src/entry.js')
1110
b.transform(require('..'), {
1211
plugin: [
1312
'postcss-import',
1413
'postcss-advanced-variables',
1514
['postcss-custom-url', [
1615
['inline', { maxSize: 10 }],
17-
['copy', { assetOutFolder: __dirname + '/static/assets' }],
16+
['copy', {
17+
assetOutFolder: __dirname + '/static/assets',
18+
baseUrl: 'assets',
19+
name: '[name].[hash]',
20+
}],
1821
]],
1922
],
2023
basedir: __dirname + '/src',
21-
postCssOptions: function (file) {
22-
return { from: file, to: to }
23-
},
2424
inject: true,
2525
})
2626
b.bundle().pipe(
27-
fs.createWriteStream(to)
27+
fs.createWriteStream(__dirname + '/static/bundle.js')
2828
)
File renamed without changes.

0 commit comments

Comments
 (0)