Skip to content

Commit ec9914e

Browse files
committed
bump to postcss 8, bump dependencies, improve speed using postcss 8 api
1 parent 0fb125f commit ec9914e

File tree

4 files changed

+50
-36
lines changed

4 files changed

+50
-36
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
}
3535
```
3636

37+
### Installation
38+
`npm install --save-dev postcss postcss-replace-overflow-wrap`
39+
3740
## Usage
3841

3942
```js

index.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
var postcss = require('postcss')
1+
// @ts-check
22

3-
module.exports = postcss.plugin('postcss-replace-overflow-wrap', function (opts) {
4-
opts = opts || {}
5-
var method = opts.method || 'replace'
3+
module.exports = function (opts) {
4+
opts = opts || {}
5+
var method = opts.method || 'replace'
6+
return {
7+
postcssPlugin: 'postcss-replace-overflow-wrap',
8+
Declaration: {
9+
'overflow-wrap': decl => {
10+
decl.cloneBefore({ prop: 'word-wrap' })
11+
if (method === 'replace') {
12+
decl.remove()
13+
}
14+
}
15+
}
16+
}
17+
}
618

7-
return function (css) {
8-
css.walkDecls('overflow-wrap', function (decl) {
9-
decl.cloneBefore({ prop: 'word-wrap' })
10-
if (method === 'replace') {
11-
decl.remove()
12-
}
13-
})
14-
}
15-
})
19+
module.exports.postcss = true

package.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
"files": [
2020
"index.js"
2121
],
22-
"dependencies": {
23-
"postcss": "^7.0.2"
24-
},
22+
"dependencies": {},
2523
"devDependencies": {
2624
"ava": "^0.25.0",
2725
"eslint": "^5.3.0",
@@ -34,7 +32,11 @@
3432
"eslint-plugin-node": "^7.0.1",
3533
"eslint-plugin-promise": "^3.8.0",
3634
"eslint-plugin-security": "^1.4.0",
37-
"eslint-plugin-standard": "^3.1.0"
35+
"eslint-plugin-standard": "^3.1.0",
36+
"postcss": "^8.0.3"
37+
},
38+
"peerDependencies": {
39+
"postcss": "^8.0.3"
3840
},
3941
"scripts": {
4042
"test": "ava && eslint *.js"
@@ -43,7 +45,12 @@
4345
"extends": "eslint-config-postcss/es5",
4446
"rules": {
4547
"max-len": 0,
46-
"es5/no-modules": false
48+
"es5/no-modules": false,
49+
"indent": [
50+
"warn",
51+
4
52+
],
53+
"es5/no-arrow-functions": 0
4754
}
4855
}
4956
}

test.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@ import test from 'ava'
33

44
import plugin from './'
55

6-
function run (t, input, output, opts = { }) { //eslint-disable-line
7-
return postcss([plugin(opts)]).process(input)
8-
.then(function (result) {
9-
t.deepEqual(result.css, output)
10-
t.deepEqual(result.warnings().length, 0)
11-
})
6+
function run(t, input, output, opts = {}) { //eslint-disable-line
7+
return postcss([plugin(opts)]).process(input)
8+
.then(function (result) {
9+
t.deepEqual(result.css, output)
10+
t.deepEqual(result.warnings().length, 0)
11+
})
1212
}
1313

1414
test('replace overflow-wrap with word-wrap, no options', function (t) {
15-
return run(t,
16-
'.someClass{ overflow-wrap: break-word; }',
17-
'.someClass{ word-wrap: break-word; }'
18-
, {})
15+
return run(t,
16+
'.someClass{ overflow-wrap: break-word; }',
17+
'.someClass{ word-wrap: break-word; }'
18+
, {})
1919
})
2020

2121
test('add word-wrap right before overflow-wrap due to passed arg', function (t) {
22-
return run(t,
23-
'.anotherClass{font-size:1rem;overflow-wrap:break-word;}',
24-
'.anotherClass{font-size:1rem;word-wrap:break-word;overflow-wrap:break-word;}'
25-
, { method: 'copy' })
22+
return run(t,
23+
'.anotherClass{font-size:1rem;overflow-wrap:break-word;}',
24+
'.anotherClass{font-size:1rem;word-wrap:break-word;overflow-wrap:break-word;}'
25+
, { method: 'copy' })
2626
})
2727

2828
test('replace overflow-wrap with word-wrap, replace method', function (t) {
29-
return run(t,
30-
'main { overflow-wrap: normal; }',
31-
'main { word-wrap: normal; }'
32-
, { method: 'replace' })
29+
return run(t,
30+
'main { overflow-wrap: normal; }',
31+
'main { word-wrap: normal; }'
32+
, { method: 'replace' })
3333
})

0 commit comments

Comments
 (0)