Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8cb8fb6

Browse files
committedSep 1, 2022
add a few commonly used things to svelte template
1 parent 7872bd2 commit 8cb8fb6

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
const path = require('path');
2+
const fs = require('fs');
3+
4+
// Commonly used dependencies: layercake for d3 charting, carbon-components for builder UIs
5+
const includedDependencies = [/layercake/, /carbon-/];
6+
7+
const getLoaderDefinition = (config, testSourceMatch, loaderMatch) =>
8+
config.module.rules
9+
.find(({ test }) => test.source.indexOf(testSourceMatch) > -1)
10+
.use.find(({ loader }) => loader.indexOf(loaderMatch || testSourceMatch) > -1);
11+
12+
module.exports = {
13+
type: 'svelte',
14+
build: {
15+
includedDependencies,
16+
entry: [
17+
"index"
18+
],
19+
},
20+
webpack: config => {
21+
// De-dupe svelte
22+
config.resolve.alias = {
23+
...(config.resolve.alias || {}),
24+
svelte: path.resolve('node_modules', 'svelte')
25+
};
26+
27+
// Disable dart-sass warnings
28+
getLoaderDefinition(config, 'scss', 'sass').options = { sassOptions: { quietDeps: true } };
29+
30+
// Disable svelte warnings when compiling dependencies
31+
getLoaderDefinition(config, 'svelte').options.onwarn = (warning, handler) => {
32+
for (const pattern of includedDependencies) {
33+
if (pattern.test(warning.filename)) {
34+
return;
35+
}
36+
}
37+
38+
handler(warning);
39+
};
40+
41+
return config;
42+
},
43+
deploy: [
44+
{
45+
to: '/www/res/sites/news-projects/<name>/<id>'
46+
},
47+
config => {
48+
fs.writeFileSync(
49+
path.join(__dirname, 'redirect', 'index.js'),
50+
`window.location = String(window.location).replace('/latest/', '/${config.id}/')`
51+
);
52+
53+
return {
54+
...config,
55+
from: 'redirect',
56+
to: '/www/res/sites/news-projects/<name>/latest'
57+
};
58+
}
59+
]
60+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
$css--font-face: false;
2+
$css--helpers: true;
3+
$css--body: true;
4+
$css--use-layer: true;
5+
$css--reset: false;
6+
$css--default-type: true;
7+
$css--plex: false;
8+
9+
//
10+
// Uncomment these to apply the styles to carbon components:
11+
//
12+
// @import 'carbon-components/scss/globals/scss/_css--helpers.scss';
13+
// @import 'carbon-components/scss/globals/scss/_css--body.scss';
14+
// @import 'carbon-components/scss/globals/grid/_grid.scss';
15+
// @import 'carbon-components/scss/components/accordion/accordion';
16+
// @import 'carbon-components/scss/components/button/button';
17+
// @import 'carbon-components/scss/components/code-snippet/code-snippet';
18+
// @import 'carbon-components/scss/components/copy-button/copy-button';
19+
// @import 'carbon-components/scss/components/notification/inline-notification';
20+
// @import 'carbon-components/scss/components/number-input/number-input';
21+
// @import 'carbon-components/scss/components/radio-button/radio-button';
22+
// @import 'carbon-components/scss/components/popover/popover';
23+
// @import 'carbon-components/scss/components/tabs/tabs';
24+
// @import 'carbon-components/scss/components/text-input/text-input';
25+
// @import 'carbon-components/scss/components/tile/tile';
26+
// @import 'carbon-components/scss/components/select/select';
27+
// @import 'carbon-components/scss/components/toggle/toggle';
28+
29+
:root {
30+
--primary: #0f62fe;
31+
--tint: #f4f4f4;
32+
}

‎src/generators/project/templates/svelte/src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { getMountValue, selectMounts } from '@abcnews/mount-utils';<% if (isTS)
44
import type { Mount } from '@abcnews/mount-utils';<% } %>
55
import App from './components/App/App.svelte';
66

7+
import './global.scss';
8+
79
let appMountEl<% if (isTS) { %>: Mount<% } %>;
810
let appProps;
911

0 commit comments

Comments
 (0)
Please sign in to comment.