Repository: getnikola/nikola

Issue:
Is webassets really required?
We currently just use `webassets` as a glorified `cat`. We should make it also minify stuff, or get rid of it and do the concatenation ourselves.


Discussion:
Since it also supports less/sass and other things, we could get rid of that part of our code.

OTOH I don't see how :-/ 
It would be nice to be able to be able to specify filters for specific files (like a CSS filter only for `output/assets/css/all.css`, so that the input CSS files aren't touched before being concatenated). Then everything webassets can do more than being a glorified `cat` could be done that way.
can i get started with this issue :)
Sure, go ahead!
as an initial step can I please know how can I get started...I am newbie to open source :)


Start with [GitHub help](https://help.github.com/) and our [Contribution guide](https://github.com/getnikola/nikola/blob/master/CONTRIBUTING.rst) and don’t hesitate to ask if you have any other questions.
Sure :)
I’m taking over due to some complaints regarding `webassets` itself being troublesome to package. I’ll just rip it out and concatenate files manually.

Resolving patch:
diff --git a/nikola/plugins/task/bundles.py b/nikola/plugins/task/bundles.py
--- a/nikola/plugins/task/bundles.py
+++ b/nikola/plugins/task/bundles.py
@@ -24,39 +24,26 @@
 # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-"""Bundle assets using WebAssets."""
+"""Bundle assets."""
 
 
 import configparser
 import io
 import itertools
 import os
-
-try:
-    import webassets
-except ImportError:
-    webassets = None  # NOQA
+import shutil
 
 from nikola.plugin_categories import LateTask
 from nikola import utils
 
 
 class BuildBundles(LateTask):
-    """Bundle assets using WebAssets."""
+    """Bundle assets."""
 
     name = "create_bundles"
 
-    def set_site(self, site):
-        """Set Nikola site."""
-        super(BuildBundles, self).set_site(site)
-        if webassets is None and site.configured and site.config['USE_BUNDLES']:
-            utils.req_missing(['webassets'], 'USE_BUNDLES', optional=True)
-            self.logger.warn('Setting USE_BUNDLES to False.')
-            site.config['USE_BUNDLES'] = False
-            site._GLOBAL_CONTEXT['use_bundles'] = False
-
     def gen_tasks(self):
-        """Bundle assets using WebAssets."""
+        """Bundle assets."""
         kw = {
             'filters': self.site.config['FILTERS'],
             'output_folder': self.site.config['OUTPUT_FOLDER'],
@@ -70,28 +57,21 @@ def gen_tasks(self):
         def build_bundle(output, inputs):
             out_dir = os.path.join(kw['output_folder'],
                                    os.path.dirname(output))
-            inputs = [os.path.relpath(i, out_dir) for i in inputs if os.path.isfile(i)]
-            cache_dir = os.path.join(kw['cache_folder'], 'webassets')
-            utils.makedirs(cache_dir)
-            env = webassets.Environment(out_dir, os.path.dirname(output),
-                                        cache=cache_dir)
-            if inputs:
-                bundle = webassets.Bundle(*inputs, output=os.path.basename(output))
-                env.register(output, bundle)
-                # This generates the file
-                try:
-                    env[output].build(force=True)
-                except Exception as e:
-                    self.logger.error("Failed to build bundles.")
-                    self.logger.exception(e)
-                    self.logger.notice("Try running ``nikola clean`` and building again.")
-            else:
-                with open(os.path.join(out_dir, os.path.basename(output)), 'wb+'):
-                    pass  # Create empty file
+            inputs = [
+                os.path.join(
+                    out_dir,
+                    os.path.relpath(i, out_dir))
+                for i in inputs if os.path.isfile(i)
+            ]
+            with open(os.path.join(out_dir, os.path.basename(output)), 'wb+') as out_fh:
+                for i in inputs:
+                    with open(i, 'rb') as in_fh:
+                        shutil.copyfileobj(in_fh, out_fh)
+                    out_fh.write(b'\n')
 
         yield self.group_task()
-        if (webassets is not None and self.site.config['USE_BUNDLES'] is not
-                False):
+
+        if self.site.config['USE_BUNDLES']:
             for name, _files in kw['theme_bundles'].items():
                 output_path = os.path.join(kw['output_folder'], name)
                 dname = os.path.dirname(name)


Test patch: