| 75 | |
| 76 | let hasGenrateCss = false; |
| 77 | function genConfig(name) { |
| 78 | const opts = builds[name]; |
| 79 | const config = { |
| 80 | input: opts.entry, |
| 81 | external: opts.external, |
| 82 | output: { |
| 83 | globals: { |
| 84 | vue: 'Vue' |
| 85 | }, |
| 86 | file: opts.dest, |
| 87 | format: opts.format, |
| 88 | banner: opts.banner, |
| 89 | name: opts.moduleName || 'vuescroll', |
| 90 | sourcemap: opts.sourcemap |
| 91 | }, |
| 92 | plugins: [ |
| 93 | resolveNode(), |
| 94 | scss({ |
| 95 | output: function(styles) { |
| 96 | if (!hasGenrateCss) { |
| 97 | hasGenrateCss = true; |
| 98 | fs.writeFileSync(resolve('dist/vuescroll.css'), styles); |
| 99 | } |
| 100 | }, |
| 101 | outputStyle: 'compressed' |
| 102 | }), |
| 103 | babel({ |
| 104 | exclude: 'node_modules/**' // only transpile our source code |
| 105 | }), |
| 106 | replace({ |
| 107 | 'process.env.NODE_FORMAT': JSON.stringify(opts.format), |
| 108 | __version__: version |
| 109 | }), |
| 110 | alias(Object.assign({}, aliases, opts.alias)) |
| 111 | ] |
| 112 | }; |
| 113 | return config; |
| 114 | } |
| 115 | |
| 116 | exports.getBuild = genConfig; |
| 117 | exports.getAllBuilds = () => Object.keys(builds).map(genConfig); |