Github CD 管道在使用 ES 模块作为配置的生产构建时崩溃
Github CD Pipelines crashes on production build with ES modules as config
我正在尝试使用 CD 部署我的 github 页面。
我的 CI 似乎可以正确地使用 es 模块作为我的 webpack 配置(https://github.com/crrmacarse/crrmacarse.github.io/actions/runs/31859113)但是当我尝试在 CD 上这样做时它崩溃并出现此错误:
这是我的 yml 配置:
name: Release
on:
push:
branches:
- source
env:
NODE_ENV: production
PUBLIC_URL: http://crrmacarse.github.io/
GA_TRACKING_CODE: ${{ secrets.GA_TRACKING_CODE }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.0.0
- name: Use node 12
uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org
- name: install
run: npm install
- name: build
run: npm run prod
# https://babeljs.io/docs/en/next/babel-node.html#not-meant-for-production-use
# - name: build sitemap
# run: npm run sitemap
- name: copy
run: npm run copy
- name: Build and Deploy
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: master
FOLDER: dist
Iirc,我是用babel-preset来实现这个ES模块导出的。哪里出错了?
这是有问题的代码
// eslint-disable-next-line import/no-dynamic-require, global-require
export default (env) => require(`./compiler/${env}.js`);
https://github.com/crrmacarse/crrmacarse.github.io/blob/source/webpack.config.babel.js
我已通过此提交修复它:
可能是删除了 NODE_ENV 或 FIREBASE_TOKEN(不存在)
我正在尝试使用 CD 部署我的 github 页面。
我的 CI 似乎可以正确地使用 es 模块作为我的 webpack 配置(https://github.com/crrmacarse/crrmacarse.github.io/actions/runs/31859113)但是当我尝试在 CD 上这样做时它崩溃并出现此错误:
这是我的 yml 配置:
name: Release
on:
push:
branches:
- source
env:
NODE_ENV: production
PUBLIC_URL: http://crrmacarse.github.io/
GA_TRACKING_CODE: ${{ secrets.GA_TRACKING_CODE }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.0.0
- name: Use node 12
uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org
- name: install
run: npm install
- name: build
run: npm run prod
# https://babeljs.io/docs/en/next/babel-node.html#not-meant-for-production-use
# - name: build sitemap
# run: npm run sitemap
- name: copy
run: npm run copy
- name: Build and Deploy
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: master
FOLDER: dist
Iirc,我是用babel-preset来实现这个ES模块导出的。哪里出错了?
这是有问题的代码
// eslint-disable-next-line import/no-dynamic-require, global-require
export default (env) => require(`./compiler/${env}.js`);
https://github.com/crrmacarse/crrmacarse.github.io/blob/source/webpack.config.babel.js
我已通过此提交修复它:
可能是删除了 NODE_ENV 或 FIREBASE_TOKEN(不存在)