Skip to content

Instantly share code, notes, and snippets.

@drschwabe
Last active June 22, 2021 22:20
Show Gist options
  • Save drschwabe/ef9fcd9ce79021c7f533fa32971938d1 to your computer and use it in GitHub Desktop.
Save drschwabe/ef9fcd9ce79021c7f533fa32971938d1 to your computer and use it in GitHub Desktop.
Watchify (Browserify) a JS file that has modules loading in both Common ('require') and ES6 ('import ... from ')
{
"name": "my-app-using-require-and-imports-same-codebase",
"scripts": {
"watch": "./node_modules/.bin/watchify client.js -t [ babelify --global --sourceType unambiguous --presets ['@babel/preset-env' ] ] -o client.bundle.js -d -v",
"compile": "./node_modules/.bin/browserify client.js -t [ babelify --global --sourceType unambiguous --presets ['@babel/preset-env' ] ] -o client.bundle.js",
"compress": "./node_modules/.bin/uglifyjs client.bundle.js --compress --mangle -o client.bundle.js",
"start": "node server.js"
},
"devDependencies": {
"@babel/polyfill": "^7.4.4",
"@babel/core": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"babelify": "^10.0.0",
"browserify": "^16.5.0",
"uglify-js": "^3.7.7",
"watchify": "^3.11.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment