Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack error on .scss when using preact build #59

Closed
jonburger opened this issue May 25, 2017 · 9 comments
Closed

Webpack error on .scss when using preact build #59

jonburger opened this issue May 25, 2017 · 9 comments

Comments

@jonburger
Copy link

jonburger commented May 25, 2017

So, I tried to add SASS support - like others I needed to npm install sass-loader node-sass postcss -D - I also needed to update the import to import './style/index.scss'

Now, when I npm run build everything seems to generate just fine except the index.html page - it contains the same error as the console, which is...

Template execution failed: SyntaxError: /preact-app/style/index.scss: Unexpected token, expected ; (1:11)
  SyntaxError: /preact-app/style/index.scss: Unexpected token, expected ; (1:11)
  > 1 | html, body {
      |            ^
    2 |  height: 100%;
    3 |  width: 100%;
    4 |  padding: 0;

Googling this error brings up lots of finger pointing at Webpack in one way or another - in particular it's an issue with SSR I think is the gist of it:

webpack-contrib/sass-loader#69
webpack/webpack#1754
react-toolbox/react-toolbox#662

It would appear that the .scss module is being interpreted as .js when it is loaded for SSR and it then fails - that's about as much as I can figure out.

@developit
Copy link
Member

developit commented May 25, 2017

@jonburger just to narrow things down, does this happen if you do preact build --no-prerender or npm run build -- --no-prerender? If so, that means it's an issue with the SSR/prerendering.

@jonburger
Copy link
Author

preact build --no-prerender and even preact build don't seem to do anything but write a list files to the console https://gist.github.com/jonburger/c5308d55511ce9d94e8cad236fb84939

npm run build -- --no-prerender does work, and doesn't exhibit the error - so it would suggest the problem is the prerendering.

@developit
Copy link
Member

@jonburger which npm/node versions are you using?

@jonburger
Copy link
Author

jonburger commented May 26, 2017

$ node -v
v7.10.0
$ npm -v
4.2.0

@developit
Copy link
Member

The preact build bit seems to be from a linked module? or the global version is lagging your local. Should work as ./node_modules/.bin/preact build --no-prerender. Definitely an prerendering issue - there's no loader defined for scss in the prerendering code. I think this is another push for using webpack to bundle code even under node.

@jonburger
Copy link
Author

So is the current suggestion for this version of preact-cli, that if prerendering is important then scss not be used?

Is there anything in the roadmap that would address these issues?

Also with Webpack's announcement of it's plan for making CSS a "first-class citizen" in that couple of days (I can't say I fully understanding the bulk of the Medium article) does that mean things will get easier in regards to prerendering?

@rkostrzewski
Copy link
Collaborator

@jonburger currently we're working on prerendering using webpack bundled code which would mean that anything that is valid in webpack is valid in prerendering. 😄

@jonburger
Copy link
Author

@rkostrzewski sounds good! 😁

@rkostrzewski
Copy link
Collaborator

Support for this landed in 1.3.0. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants