changcheng / wro4j

Automatically exported from code.google.com/p/wro4j
0 stars 0 forks source link

Allow files to be excluded #303

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm using the wro4j maven plugin to run jshint over my sources. I want to check 
all the files in a certain path, except a few files that are already minimized 
and should not be checked. The current * syntax does not allow me to do that.

Now I see two workarounds
- Include files at a more fine grained level (file-by-file): not good as I 
might forget to include new files.
- Move unchecked files to a separate path: not always that convenient.

Original issue reported on code.google.com by b3r...@gmail.com on 21 Sep 2011 at 6:05

GoogleCodeExporter commented 9 years ago
You can achieve that by creating the WroModel programmatically or extending 
JsHintProcessor and excluding the resources you are not interested in.

Original comment by alex.obj...@gmail.com on 21 Sep 2011 at 6:29

GoogleCodeExporter commented 9 years ago
Since it is possible to create multiple independent models, with each model 
being used for a specific use-case, I will close this issue with wontfix 
resolution.

Adding "exclude" functionality would add some complexity to the model and can 
be easily misused.

Please reopen this issue if you don't agree.

Original comment by alex.obj...@gmail.com on 16 Mar 2012 at 8:52

GoogleCodeExporter commented 9 years ago
FYI, I wrote a bare-bones JSHint plugin that does this: 
https://github.com/cjdev/jshint-mojo

Original comment by s...@penrose.us on 30 Aug 2012 at 6:34

GoogleCodeExporter commented 9 years ago
Reopening, since it seems to be useful after all.

Original comment by alex.obj...@gmail.com on 30 Aug 2012 at 7:36

GoogleCodeExporter commented 9 years ago
Probably filtering resources should not be done in the wro4j plugin. It is 
possible to include/exclude files with;

    <build>

        <resources>
            <resource>
                <filtering>true</filtering>
                <directory>${basedir}/src/main/modules</directory>
                <targetPath>${project.build.directory}/filtered/modules-inc</targetPath>
                <excludes>
                    <exclude>exclude.js</exclude>
                    <exclude>exclude.css</exclude>

Then point wro4j to ${project.build.directory}/filtered/modules-inc and add to 
the wro.xml a wildcard selector to all files (js/css) in the modules-inc folder

Original comment by bakker.mark on 2 Nov 2012 at 10:39

GoogleCodeExporter commented 9 years ago
The recommended approach is to group your resources in such way, that by 
specifying a group you can achieve the same thing. 

Example:

<group name="toInclude">
  <js>....</js>
</group>

<group name="toExclude">
  <js>....</js>
</group>

<group name="all">
  <group-ref>toInclude</greoup-ref>
  <group-ref>toExclude</greoup-ref>
</group>

When configuring wro4j-maven-plugin, specify the targetGroups:
<configuration>
    <targetGroups>toInclude</targetGroups>
</configuration>

Original comment by alex.obj...@gmail.com on 2 Nov 2012 at 10:45

GoogleCodeExporter commented 9 years ago
Alex,

The configuration mentioned in the last post his isn't ideal. We want to 
include all files except one or two files. Obviously we can create a group that 
excludes toExclude but it will require us to include files one by one (which is 
hard to maintain and error-prone).

Original comment by cow...@bbs.darktech.org on 15 Nov 2012 at 11:08

GoogleCodeExporter commented 9 years ago
+1 for exclude - sometimes you want to include some CSS to your site 
optionally, e.g. for older browsers. One example that comes to my mind right 
now is font awsome 
(http://fortawesome.github.io/Font-Awesome/3.2.1/get-started/#need-ie7 ): 

<link rel="stylesheet" href="path/to/font-awesome/css/font-awesome.min.css">
<!--[if IE 7]>
  <link rel="stylesheet" href="path/to/font-awesome/css/font-awesome-ie7.min.css">
<![endif]-->

but I believe this pattern is not so uncommon and usually there is fewer files 
to exclude (eg. include /static/**.css but exclude /static/**ie7.css would be 
nice - not sure about the syntax)

Original comment by stanislav.miklik on 13 Jan 2015 at 6:27