A
A
Alexey Yarkov2016-08-23 02:06:27
Node.js
Alexey Yarkov, 2016-08-23 02:06:27

How to reach bower_components?

#Структура проекта
├── bower_components
├── bower.json
├── build
├── gulp
├── gulpfile.js
├── node_modules
├── package.json
├── README.md
└── src

# Таск для gulp, эдакий минисервер для фронтенда
gulp.task('webserver', function() {
  var express = require('express');
  var server = express();
 	// это работает
  server.use(express.static(__dirname + "/build"));
 	// это КАКОГО-ТО ХРЕНА НЕ работает
  server.use('/bower_components',  express.static(__dirname + "/bower_components"));
 	// это работает
  server.all('/*', function(req, res) {
    res.sendfile(__dirname + 'build/index.html');
  });
  return server.listen(8000);
});

As a result, it has only a dull index.html without scripts and styles. What to do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kovirolik, 2016-09-11
@kovirolik

copy bower_components and json-config to /public/ , and then add the following line to your app after enabling express

app.use(express.static('public'));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question