Skip to content

Commit

Permalink
1. specific main field in package.json, and replace files field…
Browse files Browse the repository at this point in the history
… with `dist/miment.min.js`

2. replace webpack with rollup to reduce pkg size (3.16kb -> 2.86kb), and simplify the workflow
3. the script should be `dist` in `example.html` rather than source code.
  • Loading branch information
SidKwok committed Apr 18, 2018
1 parent 33b0eee commit a6f2ac8
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 1,306 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"presets": ["env"]}
{"presets": [["env", {"modules": false}]]}
2 changes: 1 addition & 1 deletion dist/miment-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions example.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,9 @@

</div>
</body>
<!--<script src="./dist/miment-min.js"></script>-->
<script src="./src/miment.js"></script>
<script src="./dist/miment-min.js"></script>
<!-- <script src="./src/miment.js"></script> -->
<script>
let miment = Miment
window.onload = function () {
// 格式化时间
var foramt = document.getElementById('foramt')
Expand Down Expand Up @@ -169,4 +168,4 @@
nativeFunction.innerHTML = '输出: ' + miment().getFullYear()
}
</script>
</html>
</html>
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
"version": "0.0.5",
"description": "a fast,light weight,simple and non-dependencies datetime library for javascript ( mini moment )",
"files": [
"./src/miment.js"
"dist/miment-min.js"
],
"main": "dist/miment-min.js",
"repository": {
"url": "https://github.com/noahlam/Miment.git",
"type": "git"
},
"author": "noahlam <[email protected]>",
"license": "MIT",
"scripts": {
"build": "webpack --config ./webpack.config.js",
"build": "rollup -c",
"test": "ava"
},
"dependencies": {},
Expand All @@ -26,6 +27,11 @@
"babel-core": "*",
"babel-loader": "^6.0.0",
"babel-preset-env": "^1.3.2",
"webpack": "2.2.0"
"rollup": "^0.58.0",
"rollup-plugin-babel": "^3.0.3",
"rollup-plugin-commonjs": "^9.1.0",
"rollup-plugin-filesize": "^1.5.0",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-uglify": "^3.0.0"
}
}
27 changes: 27 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import babel from 'rollup-plugin-babel';
import cjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
import uglify from 'rollup-plugin-uglify';
import filesize from 'rollup-plugin-filesize';

export default {
input: 'src/miment.js',
output: {
file: 'dist/miment-min.js',
name: 'miment',
format: 'umd'
},
plugins: [
babel({
exclude: 'node_modules/**'
}),
resolve({
jsnext: true,
main: true,
browser: true
}),
cjs(),
filesize(),
uglify()
]
};
31 changes: 0 additions & 31 deletions webpack.config.js

This file was deleted.

Loading

0 comments on commit a6f2ac8

Please sign in to comment.