Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vue-loader
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pi-plusplus
fork-from-github
vue-loader
Commits
2f441b92
Commit
2f441b92
authored
Aug 07, 2018
by
Chris Fritz
Committed by
Evan You
Aug 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: set file basename to __file in production (#1368)
parent
fe91c8b6
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1583 additions
and
1846 deletions
+1583
-1846
index.js
lib/index.js
+9
-4
advanced.spec.js
test/advanced.spec.js
+16
-1
yarn.lock
yarn.lock
+1558
-1841
No files found.
lib/index.js
View file @
2f441b92
...
@@ -170,10 +170,15 @@ var component = normalizer(
...
@@ -170,10 +170,15 @@ var component = normalizer(
code
+=
`\n`
+
genHotReloadCode
(
id
,
hasFunctional
,
templateRequest
)
code
+=
`\n`
+
genHotReloadCode
(
id
,
hasFunctional
,
templateRequest
)
}
}
// Expose filename. This is used by the devtools and vue runtime warnings.
// Expose filename. This is used by the devtools and Vue runtime warnings.
if
(
!
isProduction
)
{
code
+=
`\ncomponent.options.__file =
${
code
+=
`\ncomponent.options.__file =
${
JSON
.
stringify
(
rawShortFilePath
)}
`
isProduction
}
// For security reasons, only expose the file's basename in production.
?
JSON
.
stringify
(
filename
)
// Expose the file's full path in development, so that it can be opened
// from the devtools.
:
JSON
.
stringify
(
rawShortFilePath
)
}
`
code
+=
`\nexport default component.exports`
code
+=
`\nexport default component.exports`
// console.log(code)
// console.log(code)
...
...
test/advanced.spec.js
View file @
2f441b92
...
@@ -46,7 +46,7 @@ test('inherit queries on files', done => {
...
@@ -46,7 +46,7 @@ test('inherit queries on files', done => {
})
})
})
})
test
(
'expose file
name
'
,
done
=>
{
test
(
'expose file
path as __file outside production
'
,
done
=>
{
mockBundleAndRun
({
mockBundleAndRun
({
entry
:
'basic.vue'
entry
:
'basic.vue'
},
({
module
})
=>
{
},
({
module
})
=>
{
...
@@ -55,6 +55,21 @@ test('expose filename', done => {
...
@@ -55,6 +55,21 @@ test('expose filename', done => {
})
})
})
})
test
(
'expose file basename as __file in production'
,
done
=>
{
const
origNodeEnv
=
process
.
env
.
NODE_ENV
process
.
env
.
NODE_ENV
=
'production'
mockBundleAndRun
(
{
entry
:
'basic.vue'
},
({
module
})
=>
{
expect
(
module
.
__file
).
toBe
(
'basic.vue'
)
process
.
env
.
NODE_ENV
=
origNodeEnv
done
()
}
)
})
test
(
'source map'
,
done
=>
{
test
(
'source map'
,
done
=>
{
bundle
({
bundle
({
entry
:
'basic.vue'
,
entry
:
'basic.vue'
,
...
...
yarn.lock
View file @
2f441b92
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment