From fc7d4004b8ef709ea3807fb9dc8cd80b016564c9 Mon Sep 17 00:00:00 2001 From: "[bot]" Date: Mon, 28 Sep 2020 15:53:41 +0000 Subject: [PATCH] Sapper template for webpack --- .github/workflows/build-templates.yml | 18 ----- _template/build-pkg.js | 13 ---- _template/build.sh | 19 ----- _template/create-branches.sh | 25 ------ package.json | 23 ++++++ package_template.json | 49 ------------ rollup.config.js | 105 -------------------------- 7 files changed, 23 insertions(+), 229 deletions(-) delete mode 100644 .github/workflows/build-templates.yml delete mode 100644 _template/build-pkg.js delete mode 100755 _template/build.sh delete mode 100755 _template/create-branches.sh create mode 100644 package.json delete mode 100644 package_template.json delete mode 100644 rollup.config.js diff --git a/.github/workflows/build-templates.yml b/.github/workflows/build-templates.yml deleted file mode 100644 index c6e91816..00000000 --- a/.github/workflows/build-templates.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Create templates -on: - push: - branches: - - master -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: actions/setup-node@v1 - - - env: - CI: true - SSH_KEY: ${{ secrets.SSH_KEY }} - SSH_KEY_ROLLUP: ${{ secrets.SSH_KEY_ROLLUP }} - SSH_KEY_WEBPACK: ${{ secrets.SSH_KEY_WEBPACK }} - run: _template/build.sh diff --git a/_template/build-pkg.js b/_template/build-pkg.js deleted file mode 100644 index 30df9466..00000000 --- a/_template/build-pkg.js +++ /dev/null @@ -1,13 +0,0 @@ -const fs = require('fs'); - -const type = process.argv[2]; - -const pkg = require('../package_template.json'); -for (const key in pkg['merge-configs'][type]) { - Object.assign(pkg[key], pkg['merge-configs'][type][key]); -} -delete pkg['merge-configs']; -fs.writeFileSync( - __dirname + '/../package.json', - JSON.stringify(pkg, null, ' ') + '\n' -); diff --git a/_template/build.sh b/_template/build.sh deleted file mode 100755 index 7d11a13d..00000000 --- a/_template/build.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -cd "$(dirname "$0")" - -if [ "$CI" ]; then - (umask 0077; echo "$SSH_KEY" > ~/ssh_key; echo "$SSH_KEY_ROLLUP" > ~/ssh_key_rollup; echo "$SSH_KEY_WEBPACK" > ~/ssh_key_webpack) - git config user.email 'noreply@svelte.dev' - git config user.name '[bot]' -fi - -# branch names -ROLLUP=rollup -WEBPACK=webpack - -./create-branches.sh $ROLLUP $WEBPACK - -# force push rollup and webpack branches and repos -GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=accept-new -i ~/ssh_key' git push git@github.com:sveltejs/sapper-template.git $ROLLUP $WEBPACK -f -GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=accept-new -i ~/ssh_key_rollup' git push git@github.com:sveltejs/sapper-template-rollup.git $ROLLUP:master -f -GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=accept-new -i ~/ssh_key_webpack' git push git@github.com:sveltejs/sapper-template-webpack.git $WEBPACK:master -f diff --git a/_template/create-branches.sh b/_template/create-branches.sh deleted file mode 100755 index 906b65a9..00000000 --- a/_template/create-branches.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -cd "$(dirname "$0")"/.. - -HEAD=$(git rev-parse HEAD) - -ROLLUP=${1:-rollup} -WEBPACK=${2:-webpack} - -echo "Creating $ROLLUP and $WEBPACK branches from $REV" - -# create the $ROLLUP branch off the current HEAD -git symbolic-ref HEAD refs/heads/$ROLLUP -git reset $HEAD --hard -node _template/build-pkg.js rollup -git rm -r --cached .github _template package_template.json webpack.config.js -git add package.json -git commit -m 'Sapper template for Rollup' - -# create the $WEBPACK branch off the current HEAD -git symbolic-ref HEAD refs/heads/$WEBPACK -git reset $HEAD --hard -node _template/build-pkg.js webpack -git rm -r --cached .github _template package_template.json rollup.config.js -git add package.json -git commit -m 'Sapper template for webpack' diff --git a/package.json b/package.json new file mode 100644 index 00000000..85989f1a --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "TODO", + "description": "TODO", + "version": "0.0.1", + "scripts": { + "dev": "sapper dev", + "build": "sapper build", + "export": "sapper export", + "start": "node __sapper__/build" + }, + "dependencies": { + "compression": "^1.7.1", + "polka": "next", + "sirv": "^1.0.0" + }, + "devDependencies": { + "sapper": "^0.28.0", + "svelte": "^3.17.3", + "svelte-loader": "^2.9.0", + "webpack": "^4.7.0", + "webpack-modules": "^1.0.0" + } +} diff --git a/package_template.json b/package_template.json deleted file mode 100644 index ad9f8c86..00000000 --- a/package_template.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "TODO", - "description": "TODO", - "version": "0.0.1", - "scripts": { - "dev": "sapper dev", - "build": "sapper build", - "export": "sapper export", - "start": "node __sapper__/build" - }, - "dependencies": { - "compression": "^1.7.1", - "polka": "next", - "sirv": "^1.0.0" - }, - "devDependencies": { - "sapper": "^0.28.0", - "svelte": "^3.17.3" - }, - "merge-configs": { - "rollup": { - "scripts": { - "build": "sapper build --legacy", - "export": "sapper export --legacy" - }, - "devDependencies": { - "@babel/core": "^7.0.0", - "@babel/plugin-syntax-dynamic-import": "^7.0.0", - "@babel/plugin-transform-runtime": "^7.0.0", - "@babel/preset-env": "^7.0.0", - "@babel/runtime": "^7.0.0", - "@rollup/plugin-babel": "^5.0.0", - "@rollup/plugin-commonjs": "^14.0.0", - "@rollup/plugin-node-resolve": "^8.0.0", - "@rollup/plugin-replace": "^2.2.0", - "rollup": "^2.3.4", - "rollup-plugin-svelte": "^6.0.0", - "rollup-plugin-terser": "^7.0.0" - } - }, - "webpack": { - "devDependencies": { - "svelte-loader": "^2.9.0", - "webpack": "^4.7.0", - "webpack-modules": "^1.0.0" - } - } - } -} diff --git a/rollup.config.js b/rollup.config.js deleted file mode 100644 index 9aaa40c8..00000000 --- a/rollup.config.js +++ /dev/null @@ -1,105 +0,0 @@ -import resolve from '@rollup/plugin-node-resolve'; -import replace from '@rollup/plugin-replace'; -import commonjs from '@rollup/plugin-commonjs'; -import svelte from 'rollup-plugin-svelte'; -import babel from '@rollup/plugin-babel'; -import { terser } from 'rollup-plugin-terser'; -import config from 'sapper/config/rollup.js'; -import pkg from './package.json'; - -const mode = process.env.NODE_ENV; -const dev = mode === 'development'; -const legacy = !!process.env.SAPPER_LEGACY_BUILD; - -const onwarn = (warning, onwarn) => - (warning.code === 'MISSING_EXPORT' && /'preload'/.test(warning.message)) || - (warning.code === 'CIRCULAR_DEPENDENCY' && /[/\\]@sapper[/\\]/.test(warning.message)) || - onwarn(warning); - -export default { - client: { - input: config.client.input(), - output: config.client.output(), - plugins: [ - replace({ - 'process.browser': true, - 'process.env.NODE_ENV': JSON.stringify(mode) - }), - svelte({ - dev, - hydratable: true, - emitCss: true - }), - resolve({ - browser: true, - dedupe: ['svelte'] - }), - commonjs(), - - legacy && babel({ - extensions: ['.js', '.mjs', '.html', '.svelte'], - babelHelpers: 'runtime', - exclude: ['node_modules/@babel/**'], - presets: [ - ['@babel/preset-env', { - targets: '> 0.25%, not dead' - }] - ], - plugins: [ - '@babel/plugin-syntax-dynamic-import', - ['@babel/plugin-transform-runtime', { - useESModules: true - }] - ] - }), - - !dev && terser({ - module: true - }) - ], - - preserveEntrySignatures: false, - onwarn, - }, - - server: { - input: config.server.input(), - output: config.server.output(), - plugins: [ - replace({ - 'process.browser': false, - 'process.env.NODE_ENV': JSON.stringify(mode) - }), - svelte({ - generate: 'ssr', - hydratable: true, - dev - }), - resolve({ - dedupe: ['svelte'] - }), - commonjs() - ], - external: Object.keys(pkg.dependencies).concat(require('module').builtinModules), - - preserveEntrySignatures: 'strict', - onwarn, - }, - - serviceworker: { - input: config.serviceworker.input(), - output: config.serviceworker.output(), - plugins: [ - resolve(), - replace({ - 'process.browser': true, - 'process.env.NODE_ENV': JSON.stringify(mode) - }), - commonjs(), - !dev && terser() - ], - - preserveEntrySignatures: false, - onwarn, - } -};