Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support vue.config.cjs #5293

Merged
merged 5 commits into from Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/@vue/cli-service/__tests__/Service.spec.js
@@ -1,5 +1,6 @@
jest.mock('fs')
jest.mock('/vue.config.js', () => ({ lintOnSave: false }), { virtual: true })
jest.mock('/vue.config.cjs', () => ({ lintOnSave: true }), { virtual: true })
jest.mock('vue-cli-plugin-foo', () => () => {}, { virtual: true })

const fs = require('fs')
Expand Down Expand Up @@ -61,7 +62,7 @@ test('env loading for custom mode', () => {
test('loading plugins from package.json', () => {
mockPkg({
devDependencies: {
'bar': '^1.0.0',
bar: '^1.0.0',
'@vue/cli-plugin-babel': '^4.2.0',
'vue-cli-plugin-foo': '^1.0.0'
}
Expand Down Expand Up @@ -139,6 +140,13 @@ test('load project options from vue.config.js', () => {
expect(service.projectOptions.lintOnSave).toBe(false)
})

test('load project options from vue.config.cjs', () => {
fs.writeFileSync('/vue.config.cjs', '')
const service = createMockService()
fs.unlinkSync('/vue.config.cjs')
expect(service.projectOptions.lintOnSave).toBe(true)
})

test('load project options from vue.config.js', () => {
process.env.VUE_CLI_SERVICE_CONFIG_PATH = `/vue.config.js`
fs.writeFileSync('/vue.config.js', '') // only to ensure fs.existsSync returns true
Expand Down Expand Up @@ -191,7 +199,7 @@ test('api: --skip-plugins', () => {
id: 'test-command',
apply: api => {
api.registerCommand('foo', _args => {
return

})
}
},
Expand Down
5 changes: 4 additions & 1 deletion packages/@vue/cli-service/lib/Service.js
Expand Up @@ -300,10 +300,13 @@ module.exports = class Service {

loadUserOptions () {
// vue.config.js
// vue.config.cjs
let fileConfig, pkgConfig, resolved, resolvedFrom
const jsConfigPath = path.resolve(this.context, 'vue.config.js')
const cjsConfigPath = path.resolve(this.context, 'vue.config.cjs')
const configPath = (
process.env.VUE_CLI_SERVICE_CONFIG_PATH ||
path.resolve(this.context, 'vue.config.js')
(fs.existsSync(jsConfigPath) ? jsConfigPath : cjsConfigPath)
)
if (fs.existsSync(configPath)) {
try {
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Expand Up @@ -5107,7 +5107,7 @@ cheerio@^1.0.0-rc.2:
lodash "^4.15.0"
parse5 "^3.0.1"

"chokidar@>=2.0.0 <4.0.0":
"chokidar@>=2.0.0 <4.0.0", chokidar@^3.3.0:
version "3.3.1"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.3.1.tgz#c84e5b3d18d9a4d77558fef466b1bf16bbeb3450"
integrity sha512-4QYCEWOcK3OJrxwvyyAOxFuhpvOVCYkr33LPfFNBjAD/w3sEzWsp2BUOkI4l9bHvWioAd0rc6NlHUOEaWkTeqg==
Expand All @@ -5122,7 +5122,7 @@ cheerio@^1.0.0-rc.2:
optionalDependencies:
fsevents "~2.1.2"

chokidar@^2.0.0, chokidar@^2.0.2, chokidar@^2.0.3, chokidar@^2.0.4, chokidar@^2.1.8:
chokidar@^2.0.0, chokidar@^2.0.2, chokidar@^2.0.3, chokidar@^2.1.8:
version "2.1.8"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.1.8.tgz#804b3a7b6a99358c3c5c61e71d8728f041cff917"
integrity sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==
Expand Down Expand Up @@ -8352,14 +8352,14 @@ forever-agent@~0.6.1:
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=

fork-ts-checker-webpack-plugin@^1.5.1:
version "1.6.0"
resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-1.6.0.tgz#a81fd1c6bf5258fa5318cf3e9a7e9bac006f7917"
integrity sha512-vqOY5gakcoon2s12V7MMe01OPwfgqulUWFzm+geQaPPOBKjW1I7aqqoBVlU0ECn97liMB0ECs16pRdIGe9qdRw==
fork-ts-checker-webpack-plugin@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-3.1.1.tgz#a1642c0d3e65f50c2cc1742e9c0a80f441f86b19"
integrity sha512-DuVkPNrM12jR41KM2e+N+styka0EgLkTnXmNcXdgOM37vtGeY+oCBK/Jx0hzSeEU6memFCtWb4htrHPMDfwwUQ==
dependencies:
babel-code-frame "^6.22.0"
chalk "^2.4.1"
chokidar "^2.0.4"
chokidar "^3.3.0"
micromatch "^3.1.10"
minimatch "^3.0.4"
semver "^5.6.0"
Expand Down