Skip to content

Commit

Permalink
(env/refactor): split out webpack and browserify config
Browse files Browse the repository at this point in the history
- split them into files instead of command-line args in package.json
  scripts
  - webpack has a config file ofc, but wanted to keep them consistent
    initially, so used command-line
    - decided to use the browserify API as its "config file"
      - this actually took a decent amount of research to figure out
        how to output to file (have to pipe to fs stream)
  • Loading branch information
agilgur5 committed Nov 25, 2019
1 parent 6536147 commit 1cc5f7c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
7 changes: 7 additions & 0 deletions browserify.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const browserify = require('browserify')
const fs = require('fs')

browserify({
entries: './test-utils/browserify/_export-to-window.js',
}).bundle()
.pipe(fs.createWriteStream('./build/browserify.bundle.js'))
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"test": "npm run clean && npm run browserify && npm run webpack && ava",
"test:browserify": "npm run browserify && ava browserify.spec.js",
"test:webpack": "npm run webpack && ava webpack.spec.js",
"browserify": "browserify test-utils/browserify/_export-to-window.js > build/browserify.bundle.js",
"webpack": "webpack test-utils/webpack/_export-to-window.js -o build/webpack.bundle.js --mode='development'",
"browserify": "node browserify.config.js",
"webpack": "webpack",
"clean": "rm -rf build/ && mkdir build/"
},
"ava": {
Expand Down
11 changes: 11 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const path = require('path')

module.exports = {
entry: './test-utils/webpack/_export-to-window.js',
output: {
path: path.join(__dirname, '/build/'),
filename: 'webpack.bundle.js'
},
// fast builds, build is only used for testing purposes
mode: 'development'
}

0 comments on commit 1cc5f7c

Please sign in to comment.