Skip to content

Commit

Permalink
add webpack to e2e (#8602)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtoar authored Jun 13, 2023
1 parent 0bdbf66 commit fd8fbca
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,14 @@ jobs:

tutorial-e2e:
needs: check

strategy:
matrix:
os: [ubuntu-latest]
fail-fast: true
name: 🌲 Tutorial E2E / ${{ matrix.os }} / node 18 latest
runs-on: ${{ matrix.os }}
bundler: [vite, webpack]

name: 🌲 Tutorial E2E / ${{ matrix.bundler }} / node 18 latest
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

Expand All @@ -153,7 +155,10 @@ jobs:
echo "::set-output name=framework_path::$framework_path"
- name: 🌲 Create a Redwood App
run: ./tasks/run-e2e ${{ steps.createpath.outputs.project_path }} --no-start
run: |
./tasks/run-e2e ${{ steps.createpath.outputs.project_path }} \
--no-start \
--bundler ${{ matrix.bundler }}
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false

Expand Down
22 changes: 20 additions & 2 deletions tasks/run-e2e
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const buildRedwoodFramework = () => {
}
}

const createRedwoodJSApp = ({ typescript }) => {
const createRedwoodJSApp = ({ typescript, bundler }) => {
try {
execa.sync(
'yarn node dist/create-redwood-app.js',
Expand Down Expand Up @@ -86,6 +86,18 @@ const createRedwoodJSApp = ({ typescript }) => {
}

fs.writeFileSync(packageJSONPath, JSON.stringify(packageJSON, null, 2))

if (bundler === 'webpack') {
const redwoodTOMLPath = path.join(
REDWOOD_PROJECT_DIRECTORY,
'redwood.toml'
)
const redwoodTOML = fs.readFileSync(redwoodTOMLPath, 'utf-8')
fs.writeFileSync(
redwoodTOMLPath,
redwoodTOML.replace('[web]\n', '[web]\n bundler = "webpack"\n')
)
}
} catch (e) {
if (e.signal !== 'SIGINT') {
console.error('Error: Could not create Redwood Project')
Expand Down Expand Up @@ -232,6 +244,11 @@ const args = yargs(hideBin(process.argv))
.option('typescript', { default: false, type: 'boolean', alias: 'ts' })
.option('auto-start', { default: true, type: 'boolean', alias: 'start' })
.option('clean-files', { default: true, type: 'boolean' })
.option('bundler', {
default: 'vite',
type: 'string',
choices: ['vite', 'webpack'],
})
.scriptName('run-e2e')
.example('run-e2e')
.example('run-e2e /tmp/redwood-app --ts')
Expand Down Expand Up @@ -260,12 +277,13 @@ let {
copyFramework,
createProject,
typescript,
bundler,
autoStart,
cleanFiles,
} = args
const tasks = [
buildFramework && buildRedwoodFramework,
createProject && (() => createRedwoodJSApp({ typescript })),
createProject && (() => createRedwoodJSApp({ typescript, bundler })),
copyFramework && addFrameworkDepsToProject,
copyFramework && runYarnInstall,
copyFramework && copyFrameworkPackages,
Expand Down

0 comments on commit fd8fbca

Please sign in to comment.