fly-webpack
Advanced tools
Comparing version 1.0.2 to 1.0.3
26
index.js
@@ -24,16 +24,15 @@ import webpack from 'webpack'; | ||
this.webpack = function(opts, wp){ | ||
this.webpack = function(opts, wp, customCb = () => {}){ | ||
return this.defer((value, cb) => { | ||
if (!opts.output.path){ | ||
reject('output.path not defined in Webpack config'); | ||
} | ||
opts.output.path = opts.output.path || process.cwd(); | ||
opts.output.filename = opts.output.filename || '[hash].js'; | ||
if (!opts.output.filename){ | ||
opts.output.filename = "[name].entry.js"; | ||
} | ||
const done = (stats) => { | ||
if (opts.quiet){ | ||
return; | ||
} | ||
let statsOptions = opts.stats || {}; | ||
@@ -62,2 +61,6 @@ | ||
if (!files.length){ | ||
cb('source file not found'); | ||
} | ||
let entries = {}; | ||
@@ -84,2 +87,3 @@ | ||
} | ||
customCb(err, stats); | ||
}); | ||
@@ -104,3 +108,3 @@ | ||
compiler.plugin('done', (stats) => { | ||
if (opts.watch && !opts.quiet) { | ||
if (opts.watch) { | ||
done(stats); | ||
@@ -110,4 +114,4 @@ } | ||
} catch (e) { | ||
reject(e); | ||
} catch (err) { | ||
cb(err); | ||
} | ||
@@ -114,0 +118,0 @@ }); |
{ | ||
"name": "fly-webpack", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Webpack plugin for Fly.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -7,3 +7,3 @@ <div align="center"> | ||
> [Webpack](https://github.com/andrewsokolov/fly-webpack) plugin for _[Fly][fly]_. | ||
> [Webpack](http://webpack.github.io/) plugin for _[Fly][fly]_. | ||
@@ -16,6 +16,4 @@ [![][fly-badge]][fly] | ||
Under development! | ||
## Usage | ||
> Check out the [documentation](PLUGIN_DOCUMENTATION) to see the available options. | ||
> Check out the [documentation](http://webpack.github.io/docs/configuration.html) to see the available options. | ||
@@ -30,13 +28,97 @@ ### Install | ||
You can pass webpack options in with the first argument, including `watch` which will greatly decrease compilation times: | ||
```js | ||
export default function* () { | ||
yield ... | ||
let webpackConfig = { | ||
watch: true, | ||
output: { | ||
path: 'public' | ||
} | ||
}; | ||
yield this | ||
.source("src/main.js") | ||
.webpack(webpackConfig); | ||
} | ||
``` | ||
Or just pass in your `webpack.config.js`: | ||
```js | ||
export default function* () { | ||
yield this | ||
.source("src/main.js") | ||
.webpack( require('./webpack.config.js') ); | ||
} | ||
``` | ||
If you would like to use a different version of webpack than the one this plugin uses, pass in an optional 2nd argument: | ||
```js | ||
import webpack from 'webpack'; | ||
export default function* () { | ||
yield this | ||
.source("src/main.js") | ||
.webpack( require('./webpack.config.js'), webpack); | ||
} | ||
``` | ||
Pass in 3rd argument if you want to access the stats outputted from webpack when the compilation is done: | ||
```js | ||
export default function* () { | ||
yield this | ||
.source("src/main.js") | ||
.webpack({ | ||
/* config */ | ||
}, null, (err, stats) => { | ||
/* Use stats to do more things if needed */ | ||
}); | ||
} | ||
``` | ||
#### Multiple Entry Points | ||
A common request is how to handle multiple entry points. You can continue to pass in an `entry` option in your typical webpack config like so: | ||
```js | ||
export default function* () { | ||
yield this | ||
.source("src/main.js") | ||
.webpack({ | ||
entry: { | ||
app: 'src/app.js', | ||
test: 'test/test.js', | ||
}, | ||
output: { | ||
filename: '[name].js', | ||
} | ||
}); | ||
} | ||
``` | ||
Or you can handle this with passing multiple files to source like so: | ||
```js | ||
export default function* () { | ||
yield this | ||
.source(["src/app.js", "test/test.js"]) | ||
.webpack({ | ||
output: { | ||
filename: '[name].js', | ||
} | ||
}); | ||
} | ||
``` | ||
## Release History | ||
* 1.0.3 - Initial release | ||
# License | ||
[MIT][mit] © [andrewsokolov][author] et [al][contributors] | ||
[MIT][mit] © [Andrew Sokolov][author] et [al][contributors] | ||
[mit]: http://opensource.org/licenses/MIT | ||
@@ -43,0 +125,0 @@ [author]: http://github.com/andrewsokolov |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8918
92
133