Skip to content

Commit 0f954c1

Browse files
authored
Merge pull request #19 from dora-js/cwd-from-query
add option cwd and fix node@6 issue
2 parents 7c8789d + 6d6ddd6 commit 0f954c1

File tree

6 files changed

+26
-14
lines changed

6 files changed

+26
-14
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"parser": "babel-eslint",
23
"extends": "eslint-config-airbnb/base",
34
"rules": {
45
"no-console": [0]

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ publish:
44
npm publish
55

66
publish-sync: publish
7-
cnpm sync dora-plugin-webpack
8-
tnpm sync dora-plugin-webpack
7+
cnpm sync
8+
tnpm sync

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# dora-plugin-webpack
22

33

4-
webpack plugin for dora.
4+
dora plugin for webpack.
55

66

77
[![NPM version](https://img.shields.io/npm/v/dora-plugin-webpack.svg?style=flat)](https://npmjs.org/package/dora-plugin-webpack)
@@ -32,6 +32,7 @@ $ dora --plugins webpack?{"watchOptions":{"poll":true}}
3232

3333
### Options
3434

35+
- `cwd` -- default from dora
3536
- `publicPath` -- default '/', http://webpack.github.io/docs/configuration.html#output-publicpath
3637
- `config` -- default 'webpack.config.js'
3738
- `verbose` -- more logs

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "dora-plugin-webpack",
33
"version": "0.6.5",
4+
"description": "dora plugin for webpack",
45
"repository": {
56
"type": "git",
67
"url": "https://github.com/dora-js/dora-plugin-webpack"
@@ -11,11 +12,11 @@
1112
"main": "./lib",
1213
"scripts": {
1314
"build": "rm -rf lib && babel src --out-dir lib",
14-
"test": "babel-node node_modules/.bin/babel-istanbul cover node_modules/.bin/_mocha --no-timeouts",
15-
"debug": "./node_modules/.bin/mocha --require babel-core/register --no-timeouts",
15+
"test": "babel-node $(npm bin)/babel-istanbul cover $(npm bin)/_mocha --no-timeouts",
16+
"debug": "$(npm bin)/mocha --require babel-core/register --no-timeouts",
1617
"lint": "eslint --ext .js src",
1718
"coveralls": "cat ./coverage/lcov.info | coveralls",
18-
"pub":"npm run build && npm publish && rm -rf lib && git push origin"
19+
"pub": "npm run build && npm publish && rm -rf lib && git push origin"
1920
},
2021
"pre-commit": [
2122
"lint"
@@ -29,9 +30,10 @@
2930
},
3031
"devDependencies": {
3132
"atool-build": "0.x",
32-
"babel-cli": "~6.6.0",
33-
"babel-core": "~6.6.0",
34-
"babel-istanbul": "^0.5.9",
33+
"babel-cli": "^6.7.5",
34+
"babel-core": "^6.7.6",
35+
"babel-eslint": "^6.1.2",
36+
"babel-istanbul": "^0.11.0",
3537
"babel-plugin-add-module-exports": "~0.1.1",
3638
"babel-preset-es2015": "~6.1.18",
3739
"babel-preset-stage-0": "~6.1.18",
@@ -62,4 +64,4 @@
6264
"package.json",
6365
"README.md"
6466
]
65-
}
67+
}

src/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ export default {
1414
name: 'dora-plugin-webpack',
1515

1616
'middleware.before'() {
17-
const { cwd, applyPlugins, query } = this;
17+
const { applyPlugins, query } = this;
18+
let { cwd } = this;
19+
if (query.cwd) {
20+
cwd = query.cwd;
21+
}
1822
const customConfigPath = resolve(cwd, query.config || 'webpack.config.js');
1923

2024
if (existsSync(customConfigPath)) {
@@ -27,7 +31,7 @@ export default {
2731
}
2832
}
2933

30-
webpackConfig = getWebpackCommonConfig(this);
34+
webpackConfig = getWebpackCommonConfig({ ...this, cwd });
3135
webpackConfig.devtool = '#cheap-module-source-map';
3236
webpackConfig.plugins = webpackConfig.plugins.concat([
3337
new ProgressPlugin((percentage, msg) => {
@@ -71,7 +75,11 @@ export default {
7175
},
7276

7377
'server.after'() {
74-
const { cwd, query } = this;
78+
const { query } = this;
79+
let { cwd } = this;
80+
if (query.cwd) {
81+
cwd = query.cwd;
82+
}
7583
const pkgPath = join(cwd, 'package.json');
7684

7785
function getEntry() {

test/index-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('index', () => {
1616
dora({
1717
port,
1818
plugins: [
19-
'../../../src/index?publicPath=/foo/&verbose'
19+
'../../../src/index?{"publicPath": "/foo/", "verbose":true}'
2020
],
2121
cwd: cwd,
2222
verbose: true,

0 commit comments

Comments
 (0)