Skip to content

Commit

Permalink
chore(rollup): added
Browse files Browse the repository at this point in the history
  • Loading branch information
glennprofile committed Jan 9, 2020
1 parent 45f3646 commit 71c617c
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
Expand Down
1 change: 1 addition & 0 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Demo</h1>
27 changes: 24 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,35 @@
"name": "universal-loggly",
"version": "0.1.0",
"description": "loggly tool",
"main": "src/index.ts",
"main": "dist/node-universal-loggly.js",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/OnrampLab/node-universal-loggly.git"
"url": "git+https://github.com/OnrampLab/node-universal-loggly.git"
},
"dependencies": {
"cross-fetch": "^3.0.4"
},
"devDependencies": {}
"devDependencies": {
"rollup": "^1.28.0",
"rollup-plugin-buble": "^0.19.8",
"rollup-plugin-serve": "^1.0.1",
"rollup-plugin-typescript": "^1.0.1",
"rollup-plugin-uglify": "^6.0.4",
"ts-loader": "^6.2.1",
"tslib": "^1.10.0",
"typescript": "^3.7.4"
},
"scripts": {
"dev": "rollup -w -c ./tools/rollup/config.dev.js",
"prod": "rollup -c ./tools/rollup/config.prod.js"
},
"bugs": {
"url": "https://github.com/OnrampLab/node-universal-loggly/issues"
},
"homepage": "https://github.com/OnrampLab/node-universal-loggly#readme",
"keywords": [
"loggly"
],
"author": "onramplab"
}
40 changes: 40 additions & 0 deletions tools/rollup/config.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
process.env.NODE_ENV = 'development';

const path = require('path');
const serve = require('rollup-plugin-serve');
const configList = require('./config');

const resolveFile = function(filePath) {
return path.join(__dirname, '../..', filePath)
}

const PORT = 3009;
const devSite = `http://127.0.0.1:${PORT}`;
const devPath = path.join('example', 'index.html');
const devUrl = `${devSite}/${devPath}`;

setTimeout(()=>{
console.log(`[dev]: ${devUrl}`)
}, 1000);

configList.map((config, index) => {

config.output.sourcemap = true;

if (index === 0) {
config.plugins = [
...config.plugins,
...[
serve({
port: PORT,
contentBase: [resolveFile('')]
})
]
]
}

return config;
})


module.exports = configList;
25 changes: 25 additions & 0 deletions tools/rollup/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const path = require('path');
const buble = require('rollup-plugin-buble');
const typescript = require('rollup-plugin-typescript');
const pkg = require('../../package.json')

const resolveFile = function(filePath) {
return path.join(__dirname, '../..', filePath)
}

module.exports = [
{
input: resolveFile('src/index.ts'),
output: {
file: resolveFile(pkg.main),
// format: 'cjs', // node
// format: 'iife', // web
format: 'umd', // node + web
name: 'node_universal_loggly',
},
plugins: [
typescript(),
buble(),
],
},
]
24 changes: 24 additions & 0 deletions tools/rollup/config.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
process.env.NODE_ENV = 'production';

const path = require('path');
const { uglify } = require('rollup-plugin-uglify');
const configList = require('./config');

const resolveFile = function(filePath) {
return path.join(__dirname, '../..', filePath)
}

configList.map((config, index) => {

config.output.sourcemap = false;
config.plugins = [
...config.plugins,
...[
uglify()
]
]

return config;
})

module.exports = configList;

0 comments on commit 71c617c

Please sign in to comment.