mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-25 10:20:34 +03:00
chore: improve build config
This commit is contained in:
committed by
Alexander Lichter
parent
012873c9ac
commit
077407297b
+40
-23
@@ -4,6 +4,7 @@ import json from 'rollup-plugin-json'
|
|||||||
import babel from 'rollup-plugin-babel'
|
import babel from 'rollup-plugin-babel'
|
||||||
import buble from 'rollup-plugin-buble'
|
import buble from 'rollup-plugin-buble'
|
||||||
import { terser } from 'rollup-plugin-terser'
|
import { terser } from 'rollup-plugin-terser'
|
||||||
|
import defaultsDeep from 'lodash/defaultsDeep'
|
||||||
|
|
||||||
const pkg = require('../package.json')
|
const pkg = require('../package.json')
|
||||||
|
|
||||||
@@ -14,48 +15,64 @@ const banner = `/**
|
|||||||
*/
|
*/
|
||||||
`.replace(/ {4}/gm, '').trim()
|
`.replace(/ {4}/gm, '').trim()
|
||||||
|
|
||||||
const baseConfig = {
|
function rollupConfig({
|
||||||
|
plugins = [],
|
||||||
|
...config
|
||||||
|
}) {
|
||||||
|
|
||||||
|
return defaultsDeep({}, config, {
|
||||||
input: 'src/browser.js',
|
input: 'src/browser.js',
|
||||||
output: {
|
output: {
|
||||||
file: pkg.web,
|
|
||||||
format: 'umd',
|
|
||||||
name: 'VueMeta',
|
name: 'VueMeta',
|
||||||
|
format: 'umd',
|
||||||
sourcemap: false,
|
sourcemap: false,
|
||||||
banner
|
banner
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
json(),
|
json(),
|
||||||
nodeResolve(),
|
nodeResolve()
|
||||||
commonjs(),
|
].concat(plugins),
|
||||||
/*buble({
|
})
|
||||||
objectAssign: 'Object.assign'
|
|
||||||
}),*/
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default [{
|
const babelConfig = {
|
||||||
...baseConfig,
|
runtimeHelpers: true,
|
||||||
}, {
|
exclude : 'node_modules/**',
|
||||||
...baseConfig,
|
presets: [['@nuxt/babel-preset-app', {
|
||||||
|
// useBuiltIns: 'usage',
|
||||||
|
// target: { ie: 9 }
|
||||||
|
}]]
|
||||||
|
}
|
||||||
|
|
||||||
|
export default [
|
||||||
|
rollupConfig({
|
||||||
|
output: {
|
||||||
|
file: pkg.web,
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
babel(babelConfig),
|
||||||
|
commonjs()
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
rollupConfig({
|
||||||
output: {
|
output: {
|
||||||
...baseConfig.output,
|
|
||||||
file: pkg.web.replace('.js', '.min.js'),
|
file: pkg.web.replace('.js', '.min.js'),
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
...baseConfig.plugins,
|
babel(babelConfig),
|
||||||
babel({
|
commonjs(),
|
||||||
runtimeHelpers: true,
|
|
||||||
presets: ['@nuxt/babel-preset-app']
|
|
||||||
}),
|
|
||||||
terser()
|
terser()
|
||||||
]
|
]
|
||||||
}, {
|
}),
|
||||||
...baseConfig,
|
rollupConfig({
|
||||||
input: 'src/index.js',
|
input: 'src/index.js',
|
||||||
output: {
|
output: {
|
||||||
...baseConfig.output,
|
|
||||||
file: pkg.main,
|
file: pkg.main,
|
||||||
format: 'cjs'
|
format: 'cjs'
|
||||||
},
|
},
|
||||||
|
plugins: [
|
||||||
|
commonjs()
|
||||||
|
],
|
||||||
external: Object.keys(pkg.dependencies)
|
external: Object.keys(pkg.dependencies)
|
||||||
}]
|
})
|
||||||
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user