Skip to content

Commit

Permalink
Fix css-loader issues
Browse files Browse the repository at this point in the history
  • Loading branch information
artemave committed Oct 14, 2020
1 parent ec84d11 commit 5095551
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions template/js/js/browser/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const {html: h} = require('hyperdom')
const {hello} = require('./styles.css')
const logo = require('./hyperdom.png')
// This is because we require css/png differently (not via webpack) in electron tests
// and the latter generates cjs modules, whereas the former is es6.
const {hello} = require('./styles.css').default || require('./styles.css')
const logo = require('./hyperdom.png').default || require('./hyperdom.png')

module.exports = class App {
render () {
Expand Down
4 changes: 2 additions & 2 deletions template/js/jsx/browser/app.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import hyperdom from 'hyperdom'
import {hello} from './styles.css'
import styles from './styles.css'
import logo from './hyperdom.png'

export default class App {
render () {
return (
<main>
<h1 class={hello}>Hello from Hyperdom!</h1>
<h1 class={styles.hello}>Hello from Hyperdom!</h1>
<img class='logo' src={logo} width={120} />
</main>
)
Expand Down
4 changes: 2 additions & 2 deletions template/tsx/browser/app.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as hyperdom from 'hyperdom'
import {hello} from './styles.css'
import styles from './styles.css'
import logo from './hyperdom.png'

export default class App extends hyperdom.RenderComponent {
public render () {
return (
<main>
<h1 className={hello}>Hello from Hyperdom!</h1>
<h1 className={styles.hello}>Hello from Hyperdom!</h1>
<img class='logo' src={logo} width={120} />
</main>
)
Expand Down
4 changes: 2 additions & 2 deletions test/createAppSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ describe('yarn create hyperdom-app', function () {
describeCreateHyperdomApp(['--jsx'], function () {
it('generates jsx', async function () {
const index = await fs.readFile(`${sh.cwd}/browser/app.jsx`, 'utf-8')
expect(index).to.include('<h1 class={hello}>Hello from Hyperdom!</h1>')
expect(index).to.include('<h1 class={styles.hello}>Hello from Hyperdom!</h1>')
})
})
describeCreateHyperdomApp(['--tsx'], function () {
it('generates tsx', async function () {
const index = await fs.readFile(`${sh.cwd}/browser/app.tsx`, 'utf-8')
expect(index).to.include('<h1 className={hello}>Hello from Hyperdom!</h1>')
expect(index).to.include('<h1 className={styles.hello}>Hello from Hyperdom!</h1>')
})
})
})

0 comments on commit 5095551

Please sign in to comment.