-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: separate dev and prod builds (#2549)
Previously we shipped only one distribution, which could be used for any purpose. We now provide both a production and a development build. The production build is minified and any warning (usually printed to the console) is removed. --------- Co-authored-by: Jeremias Peier <[email protected]>
- Loading branch information
1 parent
df612ab
commit 909b2e0
Showing
14 changed files
with
87 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
@use 'sass:math'; | ||
|
||
/** | ||
* size: value in px (no unit) | ||
*/ | ||
@function px-to-rem-build($size) { | ||
/* size: value in px (no unit) */ | ||
@return ((math.div($size, 16)) * 1rem); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { readFileSync } from 'fs'; | ||
import { dirname, join, relative } from 'path'; | ||
|
||
import * as glob from 'glob'; | ||
import type { PluginOption, ResolvedConfig } from 'vite'; | ||
|
||
import { root } from './build-meta'; | ||
|
||
export function copySass(sassRoot: string): PluginOption { | ||
let viteConfig: ResolvedConfig; | ||
return { | ||
name: 'package-json-templating', | ||
configResolved(config) { | ||
viteConfig = config; | ||
}, | ||
generateBundle() { | ||
if (viteConfig.command !== 'build') { | ||
return; | ||
} | ||
for (const file of glob.sync(`${sassRoot}/**/*.scss`, { cwd: viteConfig.root })) { | ||
this.emitFile({ | ||
type: 'asset', | ||
fileName: file, | ||
source: readFileSync(join(viteConfig.root, file), 'utf8').replace( | ||
/@use '(node_modules\/[^']+)'/g, | ||
(_m, useFile: string) => { | ||
const outFile = join(sassRoot, useFile.replaceAll('/', '_')); | ||
this.emitFile({ | ||
type: 'asset', | ||
fileName: outFile, | ||
source: readFileSync(new URL(useFile, root), 'utf8'), | ||
}); | ||
return `@use '${relative(dirname(file), outFile)}'`; | ||
}, | ||
), | ||
}); | ||
} | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters