const fs = require('fs')
+const globby = require('globby')
const path = require('path')
const chalk = require('chalk')
const { gzipSync } = require('zlib')
)
}
-checkFileSize(path.resolve(__dirname, '../size-checks/dist/small.js'))
+const paths = globby.sync(path.resolve(__dirname, '../size-checks/dist/*.js'))
+
+for (const file of paths) {
+ checkFileSize(file)
+}
import commonjs from '@rollup/plugin-commonjs'
import { terser } from 'rollup-plugin-terser'
-/** @type {import('rollup').RollupOptions} */
-const config = {
- external: ['vue'],
- output: {
- file: path.resolve(__dirname, './dist/small.js'),
- format: 'es',
- },
- input: path.resolve(__dirname, './small.js'),
- plugins: [
- replace({
- preventAssignment: true,
- values: {
- __DEV__: 'false',
- 'process.env.NODE_ENV': JSON.stringify('production'),
- // this is only used during tests
- __TEST__: 'false',
- // If the build is expected to run directly in the browser (global / esm builds)
- __BROWSER__: 'true',
- // is targeting bundlers?
- __BUNDLER__: 'false',
- __GLOBAL__: 'false',
- // is targeting Node (SSR)?
- __NODE_JS__: 'false',
- __VUE_PROD_DEVTOOLS__: 'false',
- },
- }),
- ts({
- check: false,
- tsconfig: path.resolve(__dirname, '../tsconfig.json'),
- cacheRoot: path.resolve(__dirname, '../node_modules/.rts2_cache'),
- tsconfigOverride: {
- compilerOptions: {
- sourceMap: false,
- declaration: false,
- declarationMap: false,
- },
- exclude: ['__tests__', 'test-dts'],
- },
- }),
- resolve(),
- commonjs(),
- terser({
- format: {
- comments: false,
- },
- module: true,
- compress: {
- ecma: 2015,
- pure_getters: true,
- },
- }),
- ],
-}
+/** @type {import('rollup').RollupOptions[]} */
+const config = ['option-store', 'setup-store'].map(createConfig)
export default config
+
+/**
+ *
+ * @param {string} file
+ * @returns {import('rollup').RollupOptions}
+ */
+function createConfig(file) {
+ return {
+ external: ['vue'],
+ output: {
+ file: path.resolve(__dirname, `./dist/${file}.js`),
+ format: 'es',
+ },
+ input: path.resolve(__dirname, `./${file}.js`),
+ plugins: [
+ replace({
+ preventAssignment: true,
+ values: {
+ __DEV__: 'false',
+ 'process.env.NODE_ENV': JSON.stringify('production'),
+ // this is only used during tests
+ __TEST__: 'false',
+ // If the build is expected to run directly in the browser (global / esm builds)
+ __BROWSER__: 'true',
+ // is targeting bundlers?
+ __BUNDLER__: 'false',
+ __GLOBAL__: 'false',
+ // is targeting Node (SSR)?
+ __NODE_JS__: 'false',
+ __VUE_PROD_DEVTOOLS__: 'false',
+ },
+ }),
+ ts({
+ check: false,
+ tsconfig: path.resolve(__dirname, '../tsconfig.json'),
+ cacheRoot: path.resolve(__dirname, '../node_modules/.rts2_cache'),
+ tsconfigOverride: {
+ compilerOptions: {
+ sourceMap: false,
+ declaration: false,
+ declarationMap: false,
+ },
+ exclude: ['__tests__', 'test-dts'],
+ },
+ }),
+ resolve(),
+ commonjs(),
+ terser({
+ format: {
+ comments: false,
+ },
+ module: true,
+ compress: {
+ ecma: 2015,
+ pure_getters: true,
+ },
+ }),
+ ],
+ }
+}