Skip to content

Commit

Permalink
Add options to speficy source and artifacts directories
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroyuki Ikezoe committed Apr 5, 2018
1 parent 2685ab4 commit 69ff2d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
11 changes: 11 additions & 0 deletions README.md
@@ -1,2 +1,13 @@
# web-ext-webpack-plugin
A webpack plugin for web-ext

**webpack.config.js**
```js
const WebExtWebpackPlugin = require('web-ext-webpack-plugin');

module.exports = {
plugins: [
new WebExtWebpackPlugin({ sourceDir: './extension-dist' })
]
}
```
18 changes: 10 additions & 8 deletions web-ext-webpack-plugin.js
Expand Up @@ -6,28 +6,30 @@ const webExt = require('web-ext').default;
const pluginName = 'WebExtWebpackPlugin';

class WebExtWebpackPlugin {
constructor() {
constructor({
sourceDir = process.cwd(),
artifactsDir = path.join(sourceDir, 'web-ext-artifacts')
} = {}) {
this.runner = null;
this.watchMode = false;
this.sourceDir = sourceDir;
this.artifactsDir = artifactsDir;
}

apply(compiler) {
const sourceDir = process.cwd();
const artifactsDir = path.join(sourceDir, 'web-ext-artifacts');

const watchRun = async (compiler) => {
this.watchMode = true;
};

const afterEmit = async (compilation) => {
try {
await webExt.cmd.lint({
artifactsDir,
artifactsDir: this.artifactsDir,
boring: false,
metadata: false,
output: 'text',
pretty: false,
sourceDir,
sourceDir: this.sourceDir,
verbose: false,
warningsAsErrors: true,
}, {
Expand All @@ -44,8 +46,8 @@ class WebExtWebpackPlugin {
}

await webExt.cmd.run({
sourceDir,
artifactsDir,
sourceDir: this.sourceDir,
artifactsDir: this.artifactsDir,
noReload: true,
}, { }).then((runner) => this.runner = runner);

Expand Down

0 comments on commit 69ff2d3

Please sign in to comment.