A
A
AnatolyZ2015-03-17 07:29:26
gulp.js
AnatolyZ, 2015-03-17 07:29:26

gulp-connect. How to properly include /bower_components?

Good day to all. I apologize in advance if something is wrong.
I comprehend the wonderful world of frontend and get acquainted with gulp. There was a problem which solution anywhere did not meet yet.
Brief preamble:
I have a project with the following structure:
07225cc110d84db4aa17c98f7e7a8161.jpg
SPA application and by accessing localhost:8080 you need to get the index.html page
Added the gulp-connect server to gulpfile.js :

gulp.task('connect', function() {
    connect.server({
        root: 'src',
        livereload: true
    });
});

Thus, when accessing localhost:8080, I get the desired index.html page, but
the essence of the problem is as follows:
When the page is opened, the RequireJS I need is not loaded, which is located in the /bower_components directory adjacent to /src:
...
<script src="../bower_components/requirejs/require.js" data-main="requireConfig"></script>
...

src="../bower_components/requirejs/require.js" works if you just open the index.html file in the browser, but through gulp-connect you get a quite predictable and obvious error.
In my opinion, the solution to the problem was to change the link to
src="bower_components/requirejs/require.js"
and change the root parameter to
root: '[./src', './'],
But the entire project directory gets into the server.
Less miserable:
src="requirejs/require.js"
and
root: '[./src', './bower_components'],
And as I understand it, if in both folders in root there is a suitable resource src="requirejs/require.js" (or something else), then the lottery begins.
There is an interest: is it possible to configure gulp-connect in such a way that in html it would be possible to explicitly specify
src="bower_components/requirejs/require.js"
and include the /bower_components directory in the server by binding to requests like /bower_components/some/path?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question