Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit

Permalink
chore: Build minimized ES6 module distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
matsp committed Jan 29, 2018
1 parent 806c036 commit c203231
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 14 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ script:
- yarn build:prod
- yarn build:lib
- yarn build:es5
- yarn build:es6
after_script: greenkeeper-lockfile-upload
deploy:
- provider: pages
Expand Down
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ Material-components-vue integrates the mdc-web vanilla components following the
* keep the components as simple as possible (KISS, DRY)
* keep in sync with changes in the mdc-web repository

## distributions
| Name | ECMA | Minimized |
| ---- | --- | --- | --------- |
| dist/material-components-vue.umd.js | 6 | no |
| dist/material-components-vue.umd.min.js | 6 | yes |
| dist/material-components-vue.umd.es5.min.js | 5 | yes |

## quick start

### links
Expand Down Expand Up @@ -69,9 +76,6 @@ yarn add material-components-vue

### bundler

You have to set up your own build workflow with webpack (see demo) or something else
to compile the components.

#### import all components
```javascript
import MaterialComponentsVue from 'material-components-vue'
Expand Down Expand Up @@ -99,7 +103,7 @@ Import the SASS file in the root component of app for maximal customization.
$mdc-theme-primary: #2196f3;
$mdc-theme-secondary: #ff1744;
$mdc-theme-background: #f5f5f5;
@import '~material-components-vue/components/Theme/theme.scss';
@import '~material-components-vue/components/material-components-vue.scss';
@import url('https://cdnjs.com/libraries/normalize');
@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');
Expand Down Expand Up @@ -133,3 +137,12 @@ data() {
}
}
```

```html
<style lang="css">
@import '~material-components-vue/dist/material-components-vue.css';
@import url('https://cdnjs.com/libraries/normalize');
@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');
</style>
```
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
},
"homepage": "https://matsp.github.io/material-components-vue",
"style": "dist/material-component-vue.css",
"main": "dist/material-component-vue.js",
"main": "dist/material-component-vue.umd.js",
"module": "components/index.js",
"unpkg": "dist/material-components-vue.min.js",
"unpkg": "dist/material-components-vue.umd.es5.min.js",
"scripts": {
"lint": "eslint --ext .js --ext .vue --fix ./",
"build:dev": "webpack --config webpack.config.dev.js",
"build:prod": "webpack --config webpack.config.prod.js",
"build:lib": "webpack --config webpack.config.lib.js",
"build:es5": "webpack --config webpack.config.lib.es5.js",
"build:es6": "webpack --config webpack.config.lib.es6.js",
"serve": "./node_modules/.bin/webpack-dev-server --config ./webpack.config.dev.js",
"release": "standard-version"
},
Expand Down
6 changes: 0 additions & 6 deletions webpack.config.lib.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ const nodeModules = path.join(root, '/node_modules/')
module.exports = {
name: 'material-components-vue',
entry: path.resolve(components + 'index.js'),
output: {
path: path.resolve(root + '/dist'),
filename: 'material-components-vue.min.js',
libraryTarget: 'umd',
library: 'material-components-vue'
},
module: {
rules: [
{
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.lib.es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const nodeModules = path.join(root, '/node_modules/')
module.exports = merge(common, {
output: {
path: path.resolve(root + '/dist'),
filename: 'material-components-vue.min.js',
filename: 'material-components-vue.umd.es5.min.js',
libraryTarget: 'umd',
library: 'material-components-vue'
},
Expand Down
24 changes: 24 additions & 0 deletions webpack.config.lib.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const path = require('path')
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
const merge = require('webpack-merge')
const common = require('./webpack.config.lib.common.js')

const root = path.join(__dirname)

module.exports = merge(common, {
output: {
path: path.resolve(root + '/dist'),
filename: 'material-components-vue.umd.min.js',
libraryTarget: 'umd',
library: 'material-components-vue'
},
plugins: [
new UglifyJSPlugin({
uglifyOptions: {
ecma: 6
},
cache: true,
parallel: true
})
]
})
2 changes: 1 addition & 1 deletion webpack.config.lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const root = path.join(__dirname)
module.exports = merge(common, {
output: {
path: path.resolve(root + '/dist'),
filename: 'material-components-vue.js',
filename: 'material-components-vue.umd.js',
libraryTarget: 'umd',
library: 'material-components-vue'
}
Expand Down

0 comments on commit c203231

Please sign in to comment.