Skip to content

Commit

Permalink
feat: add es build to work better with bundlers
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Nov 20, 2018
1 parent 825924e commit 2a65bce
Show file tree
Hide file tree
Showing 11 changed files with 249 additions and 45 deletions.
7 changes: 3 additions & 4 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module.exports = {
plugins: [
'@babel/plugin-syntax-object-rest-spread',
['module:fast-async', {
spec: true
presets: [
['minimal', {
mode: 'loose'
}]
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
/lib
19 changes: 0 additions & 19 deletions build/plugins/buble.js

This file was deleted.

3 changes: 0 additions & 3 deletions build/poi.lib.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ module.exports = {
plugins: [
{
resolve: lib
},
{
resolve: require('./plugins/buble')
}
],
filenames: {
Expand Down
7 changes: 1 addition & 6 deletions build/poi.website.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,5 @@ module.exports = {
__DOCUTE_VERSION__: JSON.stringify(pkg.version),
__PRISM_VERSION__: JSON.stringify(require('prismjs/package').version),
__DEPS__: JSON.stringify(Object.keys(pkg.dependencies))
},
plugins: [
{
resolve: require('./plugins/buble')
}
]
}
}
9 changes: 9 additions & 0 deletions build/sfc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
input: 'src',
outDir: 'lib',
include: '**',
constants: {
__DOCUTE_VERSION__: JSON.stringify(require('../package').version),
__PRISM_VERSION__: JSON.stringify(require('prismjs/package').version)
}
}
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"name": "docute",
"version": "0.0.0-managed-by-semantic-release",
"scripts": {
"build": "poi build --config build/poi.lib.config.js --target lib",
"build:umd": "poi build --config build/poi.lib.config.js --target lib",
"build:es": "sfc normalize --config build/sfc.config.js",
"build": "npm run build:umd && npm run build:es",
"test": "npm run lint && echo 'no tests!'",
"lint": "xo",
"website": "poi dev --config build/poi.website.config.js",
Expand All @@ -27,8 +29,7 @@
"devDependencies": {
"@babel/plugin-syntax-object-rest-spread": "^7.0.0",
"@leptosia/docute-google-analytics": "^1.0.0",
"buble": "^0.19.3",
"buble-loader": "^0.5.1",
"babel-preset-minimal": "^0.1.1",
"cz-conventional-changelog": "^2.1.0",
"eslint-config-rem": "^3.0.0",
"eslint-plugin-vue": "^5.0.0-beta.3",
Expand All @@ -39,6 +40,7 @@
"postcss-import": "^12.0.0",
"postcss-preset-env": "^6.0.3",
"semantic-release": "^15.12.0",
"sfc": "^0.2.12",
"webpack-node-externals": "^1.7.2",
"xo": "^0.23.0"
},
Expand All @@ -47,8 +49,10 @@
"type": "git"
},
"main": "dist/docute.js",
"module": "lib/index.js",
"files": [
"dist"
"dist",
"lib"
],
"description": "Effortlessly documentation done right.",
"author": "egoist <[email protected]>",
Expand Down
32 changes: 32 additions & 0 deletions website/docs/guide/use-with-bundlers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Use With Bundlers

You don't have to use a bundler in order to use Docute, however if you want, you can!

First you need to install Docute as a dependency in your project:

```bash
yarn add docute --dev
```

Then see below for the usage with your bundler of choice.

## Webpack

In your entry file:

```js
import Docute from 'docute'

new Docute({
target: '#app',
// Other options
})
```

You may need to use [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin) to generate an HTML file too.

If you're using [Vue CLI](https://cli.vuejs.org) or [Poi](https://poi.js.org), congratulations, there's no more build configs needed.

## Parcel

[TODO] [PR WELCOME]
32 changes: 32 additions & 0 deletions website/docs/zh/guide/use-with-bundlers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Use With Bundlers

You don't have to use a bundler in order to use Docute, however if you want, you can!

First you need to install Docute as a dependency in your project:

```bash
yarn add docute --dev
```

Then see below for the usage with your bundler of choice.

## Webpack

In your entry file:

```js
import Docute from 'docute'

new Docute({
target: '#app',
// Other options
})
```

You may need to use [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin) to generate an HTML file too.

If you're using [Vue CLI](https://cli.vuejs.org) or [Poi](https://poi.js.org), congratulations, there's no more build configs needed.

## Parcel

[TODO] [PR WELCOME]
18 changes: 18 additions & 0 deletions website/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ new Docute({
}
]
},
{
title: 'Advanced',
links: [
{
title: 'Use With Bundlers',
link: '/guide/use-with-bundlers'
}
]
},
{
title: 'References',
links: [
Expand Down Expand Up @@ -143,6 +152,15 @@ new Docute({
}
]
},
{
title: '进阶',
links: [
{
title: '使用打包工具',
link: '/zh/guide/use-with-bundlers'
}
]
},
{
title: '参考',
links: [
Expand Down
Loading

0 comments on commit 2a65bce

Please sign in to comment.