Skip to content

Commit

Permalink
fix: do not include esnext code in dist files
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsn committed May 31, 2018
1 parent 73d2bb2 commit ba63a7b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 32 deletions.
34 changes: 2 additions & 32 deletions bili.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
const fs = require('fs')
const pkg = require('./package.json')
const svelte = require('rollup-plugin-svelte')
const postcss = require('postcss')
const customProperties = require('postcss-custom-properties')
const styleVars = require('./style-vars.json')

const banner = `/*!
* ${pkg.name} v${pkg.version}
Expand All @@ -15,32 +10,7 @@ const banner = `/*!
*/`

module.exports = {
input: `dist/${pkg.name}.es.modern.js`,
moduleName: 'CalendarSet',
banner,
plugin: [
svelte({
css: handleCss
})
]
}

function handleCss({ code, map }) {
postcss({
plugins: [
customProperties({
variables: styleVars,
appendVariables: true
})
]
})
.process(code, {
from: false,
map: {
prev: map
}
})
.then(({ css, map }) => {
fs.writeFileSync(`dist/${pkg.name}.css`, css)
fs.writeFileSync(`dist/${pkg.name}.css.map`, map)
})
banner
}
37 changes: 37 additions & 0 deletions bili.config.pre.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const fs = require('fs')
const pkg = require('./package.json')
const svelte = require('rollup-plugin-svelte')
const postcss = require('postcss')
const customProperties = require('postcss-custom-properties')
const styleVars = require('./style-vars.json')

module.exports = {
filename: '[name][suffix].modern.js',
js: false,
plugin: [
svelte({
css: handleCss
})
]
}

function handleCss({ code, map }) {
postcss({
plugins: [
customProperties({
variables: styleVars,
appendVariables: true
})
]
})
.process(code, {
from: false,
map: {
prev: map
}
})
.then(({ css, map }) => {
fs.writeFileSync(`dist/${pkg.name}.css`, css)
fs.writeFileSync(`dist/${pkg.name}.css.map`, map)
})
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
},
"scripts": {
"prepublishOnly": "npm run test && npm run build",
"prebuild": "bili --format es --config bili.config.pre.js",
"build": "bili --format cjs,es,umd,umd-min",
"lint": "eslint --ext html src test",
"test": "jest",
Expand Down

0 comments on commit ba63a7b

Please sign in to comment.