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

Usage Exemple for webpack #16

Open
anthonykasabian opened this issue Feb 21, 2017 · 4 comments
Open

Usage Exemple for webpack #16

anthonykasabian opened this issue Feb 21, 2017 · 4 comments

Comments

@anthonykasabian
Copy link

Heyho and thanks for this great piece of Software. Are there some Exemple or maybe snippets how to start using Core with Tools like webpack? Would be great combination for prototyping and building Sites rapidly

@assemblebot
Copy link

@tonimain Thanks for the issue! If you're reporting a bug, please be sure to include:

  • The version of assemble you are using.
  • Your assemblefile.js (This can be in a gist)
  • The commandline output. (Screenshot or gist is fine)
  • What you expected to happen instead.

@jonschlinkert
Copy link
Member

@dtothefp weren't you using webpack with assemble core? If so do you happen to have a snippet you could share?

@dtothefp
Copy link

dtothefp commented Feb 21, 2017

@jonschlinkert I'm not sure of the exact meaning of the question but will interpret just as how you could have a local development environment where Assemble builds templates/watches & reloads templates on changes, and where Webpack builds JS/CSS and does some livereload/hot reload. Then in prod you might hash your asset paths for your JS/CSS and then build HTML that puts these asset paths into <link> and <script> tags.

The tasks in this repo show a bit of an overly complicated example https://github.com/build-boiler/making-gulp-suck-less/tree/master/build/tasks but essentially if one uses a tool like webpack-isomorphic-tools or some other webpack stats generation plugin to generate stats on their webpack compiled assets then they can consume these stats via their templating language either by loading them into the assemble context or just reading them inside of some sort of helper/template tag. In this case I made a nunjucks tag that gets the stats off of the template context https://github.com/build-boiler/making-gulp-suck-less/blob/master/build/tasks/assemble/tags/get-assets.js so in the HTML you could do something like

<head>
  {% get_asset type="css" %}
</head>
<body>
  {% get_asset type="js" %}
</body>

Everything else is just typical config for assemble and webpack, depending upon how you want to setup your local environment.

I hope that helps. The repo example would most likely be difficult to get up and running as it is a mono repo using lerna but I think it would work on first clone of the repo via

npm i -g gulp-cli # uses gulp 4
npm i
npm run lerna:bootstrap
gulp watch

The process could be stepped through if someone installs iron-node:

npm i -g iron-node@latest
# place a debugger somewhere in the webpack or assemble task
iron-node `which gulp` <task_name>

@jonschlinkert
Copy link
Member

awesome, thanks! that helps. we've been working on docs (hence the recent flood of new plugins and helpers), so some of this will get easier for users to understand how to do on their own.

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

4 participants