Coder Social home page Coder Social logo

Comments (9)

paulirish avatar paulirish commented on May 20, 2024

It'd be cool but mostly we'd require your help in adding the feature. :)

from ant-build-script.

alvincrespo avatar alvincrespo commented on May 20, 2024

Sounds good to me. I've already forked it and modifying the build.xml to account for requirejs/amd. Can this ticket be assigned to me?

from ant-build-script.

paulirish avatar paulirish commented on May 20, 2024

can't assign it to you but you certainly own it. (in our hearts)

from ant-build-script.

roblarsen avatar roblarsen commented on May 20, 2024

How do you picture this working, from an end user perspective?

Also, in lieu of assigning it to you, I can walk downstairs every couple of hours to see how it's going...

from ant-build-script.

alvincrespo avatar alvincrespo commented on May 20, 2024

@roblarsen I was thinking of basically including the option to set a property, named script.amd, within project.properties to something like amd or amd.jquery with the default being empty for the default behavior that we currently see.

This is what I was thinking of doing, its a bit messy but I'll clean it up eventually before submitting a request:

<echo message="Update the HTML to reference our concatenated script file: ${scripts.js}"/>
<!-- Determines which Regex to use for AMD use -->
<if>
    <equals arg1="${script.type}" arg2="amd"/>
    <then>
        <echo message="Updating HTML to reflect the use of RequireJS"/>
        <property name="matchRegex" value="&lt;!-- scripts concatenated [\d\w\s\W]*&lt;script.*data-main=['&quot;]?(.*)/${file.root.script}(?:\?.*)?['&quot;]?\s*&gt;\s*&lt;/script&gt;[\d\w\s\W]*&lt;!-- end ((scripts)|(concatenated and minified scripts))\s*--&gt;" />
        <property name="replaceRegex" value="&lt;script data-main='\1/${scripts.sha}.js\' src='js/require.js'&gt;&lt;/script&gt;" />
    </then>
    <elseif>
        <equals arg1="${script.type}" arg2="amd.jquery"/>
        <then>
            <echo message="Updating HTML to reflect the use of RequireJS with jQuery"/>
            <property name="matchRegex" value="&lt;!-- scripts concatenated [\d\w\s\W]*&lt;script.*data-main=['&quot;]?(.*)/${file.root.script}(?:\?.*)?['&quot;]?\s*&gt;\s*&lt;/script&gt;[\d\w\s\W]*&lt;!-- end ((scripts)|(concatenated and minified scripts))\s*--&gt;" />
            <property name="replaceRegex" value="&lt;script data-main='\1/${scripts.sha}.js\' src='js/require-jquery.js'&gt;&lt;/script&gt;" />
        </then>
    </elseif>
    <else>
        <echo message="Updating HTML to reflect the use of default script inclusion"/>
        <property name="matchRegex" value="&lt;!-- scripts concatenated [\d\w\s\W]*&lt;script.*src=['&quot;]?(.*)/${file.root.script}(?:\?.*)?['&quot;]?\s*&gt;\s*&lt;/script&gt;[\d\w\s\W]*&lt;!-- end ((scripts)|(concatenated and minified scripts))\s*--&gt;" />
        <property name="replaceRegex" value="&lt;script src='\1/${scripts.sha}.js\'&gt;&lt;/script&gt;" />
    </else>
</if>
<!-- style.css replacement handled as a replacetoken above -->
<replaceregexp match="${matchRegex}"
  replace="${replaceRegex}" flags="m">
    <fileset dir="${dir.intermediate}" includes="${page-files}"/>
</replaceregexp>
<!--[! use comments like this one to avoid having them get minified -->

And in project.properties:

# Optional property used to determine whether to use require.js implementation of AMD
# Note: Make sure to include require.js here: js/libs/
# Set to amd to output: <script data-main='js/hash.js' src='js/require.js'></script>
# Set to amd.jquery to output: <script data-main='js/hash.js' src='js/require-jquery.js'></script>
#   If using amd.jquery remember to remove the jquery files in js/libs and the markup within index.html
script.type = amd.jquery

from ant-build-script.

roblarsen avatar roblarsen commented on May 20, 2024

I think it makes sense to set the path to require as a property. We're not shipping it, so we can't rely on it working. If we require that people set the path to require in the project properties it will force them to acknowledge that the file needs to be there and will allow them to place it anywhere (local file system, CDN) without having to touch the XML.

from ant-build-script.

alvincrespo avatar alvincrespo commented on May 20, 2024

Good idea! I didn't think about that one. Ill switch it out to use a path instead.

from ant-build-script.

roblarsen avatar roblarsen commented on May 20, 2024

Yeah, generally we want to avoid having people touch the XML. Especially for something like a path, which is an easy substitution.

from ant-build-script.

roblarsen avatar roblarsen commented on May 20, 2024

making magic.

from ant-build-script.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.