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

feat(build): add source when build #13036

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion scripts/build.js
Expand Up @@ -41,7 +41,13 @@ function buildEntry (config) {
const isProd = /(min|prod)\.js$/.test(file)
return rollup.rollup(config)
.then(bundle => bundle.generate(output))
.then(async ({ output: [{ code }] }) => {
.then(async ({ output: [{ code, map }] }) => {
const hasMap = !!map;
const filename = file.split('/').pop();
if (hasMap) {
code = code + `\n//# sourceMappingURL=${filename}.map`;
write(`${file}.map`, JSON.stringify(map));
}
if (isProd) {
const {code: minifiedCode} = await terser.minify(code, {
toplevel: true,
Expand Down
3 changes: 2 additions & 1 deletion scripts/config.js
Expand Up @@ -258,7 +258,8 @@ function genConfig(name) {
format: opts.format,
banner: opts.banner,
name: opts.moduleName || 'Vue',
exports: 'auto'
exports: 'auto',
sourcemap: !!process.env.SOURCE_MAP
},
onwarn: (msg, warn) => {
if (!/Circular/.test(msg)) {
Expand Down