Skip to content

Commit fa7ba5a

Browse files
mattlewis92JaKXz
authored andcommitted
feat: move webpack to a peer dependency and allow webpack 2 (#46)
* test: test against both webpack 1 and webpack 2 * chore: use npm install version * style: whitespace
1 parent ffbab73 commit fa7ba5a

File tree

5 files changed

+759
-71
lines changed

5 files changed

+759
-71
lines changed

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,31 @@
2727
],
2828
"homepage": "https://github.com/vieron/stylelint-webpack-plugin#readme",
2929
"peerDependencies": {
30-
"stylelint": "^7.7.0"
30+
"stylelint": "^7.7.0",
31+
"webpack": "^2 || ^2.2.0-rc.0 || ^2.1.0-beta.0 || ^1.13.2"
3132
},
3233
"dependencies": {
3334
"arrify": "^1.0.1",
3435
"chalk": "^1.1.3",
3536
"object-assign": "^4.1.0",
36-
"stylelint": "^7.7.0",
37-
"webpack": "^1.13.2"
37+
"stylelint": "^7.7.0"
3838
},
3939
"devDependencies": {
4040
"chai": "^3.5.0",
4141
"chai-as-promised": "^6.0.0",
4242
"coveralls": "^2.11.14",
4343
"memory-fs": "^0.3.0",
4444
"mocha": "^3.1.0",
45+
"npm-install-version": "^6.0.1",
4546
"nyc": "^8.3.1",
47+
"webpack": "^1.13.2",
4648
"xo": "^0.16.0"
4749
},
4850
"scripts": {
4951
"pretest": "xo",
50-
"test": "nyc mocha",
52+
"test:webpack1": "WEBPACK_VERSION=1 nyc mocha",
53+
"test:webpack2": "WEBPACK_VERSION=beta nyc mocha",
54+
"test": "npm run test:webpack1 && npm run test:webpack2",
5155
"preversion": "npm run test",
5256
"version": "git add -A ."
5357
},

test/helpers/pack.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

3-
var webpack = require('webpack');
43
var MemoryFileSystem = require('memory-fs');
4+
var webpack = require('./webpack');
55

66
/**
77
* Basic in memory compiler, promisified

test/helpers/webpack.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
var niv = require('npm-install-version');
4+
5+
var packageName = 'webpack@' + process.env.WEBPACK_VERSION;
6+
niv.install(packageName);
7+
8+
module.exports = niv.require(packageName);

test/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
'use strict';
22

33
var assign = require('object-assign');
4-
var webpack = require('webpack');
54

65
var StyleLintPlugin = require('../');
76
var pack = require('./helpers/pack');
7+
var webpack = require('./helpers/webpack');
88

99
var configFilePath = getPath('./.stylelintrc');
1010
var baseConfig = {
11-
debug: false,
1211
output: {
1312
path: getPath('output')
1413
},
@@ -20,6 +19,16 @@ var baseConfig = {
2019
]
2120
};
2221

22+
if (typeof webpack.LoaderOptionsPlugin === 'undefined') {
23+
baseConfig.debug = false;
24+
} else {
25+
baseConfig.plugins.push(
26+
new webpack.LoaderOptionsPlugin({
27+
debug: false
28+
})
29+
);
30+
}
31+
2332
describe('stylelint-webpack-plugin', function () {
2433
it('works with a simple file', function () {
2534
var config = {

0 commit comments

Comments
 (0)