-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a few commonly used things to svelte template
- Loading branch information
Showing
3 changed files
with
94 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
// Commonly used dependencies: layercake for d3 charting, carbon-components for builder UIs | ||
const includedDependencies = [/layercake/, /carbon-/]; | ||
|
||
const getLoaderDefinition = (config, testSourceMatch, loaderMatch) => | ||
config.module.rules | ||
.find(({ test }) => test.source.indexOf(testSourceMatch) > -1) | ||
.use.find(({ loader }) => loader.indexOf(loaderMatch || testSourceMatch) > -1); | ||
|
||
module.exports = { | ||
type: 'svelte', | ||
build: { | ||
includedDependencies, | ||
entry: [ | ||
"index" | ||
], | ||
}, | ||
webpack: config => { | ||
// De-dupe svelte | ||
config.resolve.alias = { | ||
...(config.resolve.alias || {}), | ||
svelte: path.resolve('node_modules', 'svelte') | ||
}; | ||
|
||
// Disable dart-sass warnings | ||
getLoaderDefinition(config, 'scss', 'sass').options = { sassOptions: { quietDeps: true } }; | ||
|
||
// Disable svelte warnings when compiling dependencies | ||
getLoaderDefinition(config, 'svelte').options.onwarn = (warning, handler) => { | ||
for (const pattern of includedDependencies) { | ||
if (pattern.test(warning.filename)) { | ||
return; | ||
} | ||
} | ||
|
||
handler(warning); | ||
}; | ||
|
||
return config; | ||
}, | ||
deploy: [ | ||
{ | ||
to: '/www/res/sites/news-projects/<name>/<id>' | ||
}, | ||
config => { | ||
fs.writeFileSync( | ||
path.join(__dirname, 'redirect', 'index.js'), | ||
`window.location = String(window.location).replace('/latest/', '/${config.id}/')` | ||
); | ||
|
||
return { | ||
...config, | ||
from: 'redirect', | ||
to: '/www/res/sites/news-projects/<name>/latest' | ||
}; | ||
} | ||
] | ||
}; |
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,32 @@ | ||
$css--font-face: false; | ||
$css--helpers: true; | ||
$css--body: true; | ||
$css--use-layer: true; | ||
$css--reset: false; | ||
$css--default-type: true; | ||
$css--plex: false; | ||
|
||
// | ||
// Uncomment these to apply the styles to carbon components: | ||
// | ||
// @import 'carbon-components/scss/globals/scss/_css--helpers.scss'; | ||
// @import 'carbon-components/scss/globals/scss/_css--body.scss'; | ||
// @import 'carbon-components/scss/globals/grid/_grid.scss'; | ||
// @import 'carbon-components/scss/components/accordion/accordion'; | ||
// @import 'carbon-components/scss/components/button/button'; | ||
// @import 'carbon-components/scss/components/code-snippet/code-snippet'; | ||
// @import 'carbon-components/scss/components/copy-button/copy-button'; | ||
// @import 'carbon-components/scss/components/notification/inline-notification'; | ||
// @import 'carbon-components/scss/components/number-input/number-input'; | ||
// @import 'carbon-components/scss/components/radio-button/radio-button'; | ||
// @import 'carbon-components/scss/components/popover/popover'; | ||
// @import 'carbon-components/scss/components/tabs/tabs'; | ||
// @import 'carbon-components/scss/components/text-input/text-input'; | ||
// @import 'carbon-components/scss/components/tile/tile'; | ||
// @import 'carbon-components/scss/components/select/select'; | ||
// @import 'carbon-components/scss/components/toggle/toggle'; | ||
|
||
:root { | ||
--primary: #0f62fe; | ||
--tint: #f4f4f4; | ||
} |
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