File tree Expand file tree Collapse file tree 2 files changed +5
-7
lines changed
packages/@vue/cli-service Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change 1
1
jest . mock ( 'fs' )
2
- jest . mock ( 'mock- config' , ( ) => ( { lintOnSave : false } ) , { virtual : true } )
2
+ jest . mock ( '/vue. config.js ' , ( ) => ( { lintOnSave : false } ) , { virtual : true } )
3
3
jest . mock ( 'vue-cli-plugin-foo' , ( ) => ( ) => { } , { virtual : true } )
4
4
5
5
const fs = require ( 'fs' )
@@ -53,16 +53,16 @@ test('load project options from package.json', () => {
53
53
} )
54
54
55
55
test ( 'load project options from vue.config.js' , ( ) => {
56
- process . env . VUE_CLI_SERVICE_CONFIG_PATH = 'mock-config'
56
+ fs . writeFileSync ( '/vue.config.js' , `module.exports = { lintOnSave: false }` )
57
57
mockPkg ( {
58
58
vue : {
59
59
lintOnSave : true
60
60
}
61
61
} )
62
62
const service = createMockService ( )
63
+ fs . unlinkSync ( '/vue.config.js' )
63
64
// vue.config.js has higher priority
64
65
expect ( service . projectOptions . lintOnSave ) . toBe ( false )
65
- delete process . env . VUE_CLI_SERVICE_CONFIG_PATH
66
66
} )
67
67
68
68
test ( 'api: setMode' , ( ) => {
Original file line number Diff line number Diff line change @@ -159,13 +159,11 @@ module.exports = class Service {
159
159
loadProjectOptions ( inlineOptions ) {
160
160
// vue.config.js
161
161
let fileConfig , pkgConfig , resolved , resovledFrom
162
- const configPath = (
163
- process . env . VUE_CLI_SERVICE_CONFIG_PATH ||
164
- path . resolve ( this . context , 'vue.config.js' )
165
- )
162
+ const configPath = path . resolve ( this . context , 'vue.config.js' )
166
163
if ( fs . existsSync ( configPath ) ) {
167
164
try {
168
165
fileConfig = require ( configPath )
166
+ console . log ( fileConfig )
169
167
if ( ! fileConfig || typeof fileConfig !== 'object' ) {
170
168
error (
171
169
`Error loading ${ chalk . bold ( 'vue.config.js' ) } : should export an object.`
You can’t perform that action at this time.
0 commit comments