File tree Expand file tree Collapse file tree 4 files changed +43
-8
lines changed
Expand file tree Collapse file tree 4 files changed +43
-8
lines changed Original file line number Diff line number Diff line change 44 "devDependencies" : {
55 "cross-env" : " ^5.2.0" ,
66 "css-loader" : " ^2.1.1" ,
7+ "linaria" : " ^1.3.3" ,
78 "mini-css-extract-plugin" : " ^0.6.0" ,
89 "serve" : " ^11.0.0" ,
910 "style-loader" : " ^0.23.1" ,
Original file line number Diff line number Diff line change 11<script >
2+ import { css } from ' linaria' ;
3+ import { externalStyle } from ' ./styles.js' ;
4+
25 export let name;
6+
7+ const localStyle = css`
8+ color: green;
9+ ` ;
310 </script >
411
512<style >
613 h1 {
714 color : purple ;
815 }
16+ code {
17+ font-size : 16px ;
18+ }
919 </style >
1020
11- <h1 >Hello {name }!</h1 >
21+ <h1 >Hello {name }!</h1 >
22+ <p class ={localStyle }>This is styled with Linaria styles in a <code >.svelte</code > file</p >
23+ <p class ={externalStyle }>This is using Linaria styles imported from a <code >.js</code > file!</p >
Original file line number Diff line number Diff line change 1+ import { css } from 'linaria' ;
2+
3+ export const externalStyle = css `
4+ font-style : italic;
5+ ` ;
Original file line number Diff line number Diff line change @@ -4,6 +4,14 @@ const path = require('path');
44const mode = process . env . NODE_ENV || 'development' ;
55const prod = mode === 'production' ;
66
7+ const linariaLoader = {
8+ loader : 'linaria/loader' ,
9+ options : {
10+ sourceMap : ! prod ,
11+ cacheDirectory : path . resolve ( __dirname , 'node_modules/.cache/.linaria-cache' )
12+ }
13+ } ;
14+
715module . exports = {
816 entry : {
917 bundle : [ './src/main.js' ]
@@ -22,15 +30,24 @@ module.exports = {
2230 } ,
2331 module : {
2432 rules : [
33+ {
34+ test : / \. m ? j s $ / ,
35+ exclude : / n o d e _ m o d u l e s / ,
36+ use : [ linariaLoader ]
37+ } ,
2538 {
2639 test : / \. s v e l t e $ / ,
27- use : {
28- loader : 'svelte-loader' ,
29- options : {
30- emitCss : true ,
31- hotReload : true
32- }
33- }
40+ use : [
41+ linariaLoader ,
42+ {
43+ loader : 'svelte-loader' ,
44+ options : {
45+ dev : ! prod ,
46+ emitCss : true ,
47+ hotReload : true
48+ } ,
49+ } ,
50+ ] ,
3451 } ,
3552 {
3653 test : / \. c s s $ / ,
You can’t perform that action at this time.
0 commit comments