Git Product home page Git Product logo

Comments (5)

nareshbhatia avatar nareshbhatia commented on August 23, 2024

The task that takes care of the injected styles is build.scss.ts. The function that you want to look at is processExternalScss(). Currently it processes only .scss files, but we need to extend it to process .css files too - the only difference is that the .css files should not pass through Sass. So it is something like this:

function processExternalScss() {
  return gulp.src([
      join(APP_SRC, 'assets', '**', '*.scss'),  // assets/main.scss etc.
      getExternalCss().map(r => r.src)          // node_modules/.../*.css etc.
    ])
    .pipe(plugins.sass(SASS_OPTIONS))
    .pipe(isProd ? plugins.cached('process-external-css') : plugins.util.noop())
    .pipe(plugins.postcss(processors))
    .pipe(isProd ? plugins.concat(CSS_PROD_BUNDLE) : plugins.util.noop())
    .pipe(gulp.dest(CSS_DEST));
}

function getExternalCss() {
  return DEPENDENCIES.filter(d => /\.css$/.test(d.src));
}

Of course, this passes the css files through sass. It doesn't hurt but it's kind of a hack. Let me know if you have any suggestions.

from angular2-seed-sass.

Geoide avatar Geoide commented on August 23, 2024

@nareshbhatia thank you very much.

Perhaps, my version would be:

function processExternalScss() {
  return merge(processAssetsCss(), processInjectedCss())
    .pipe(plugins.sass(SASS_OPTIONS))
    .pipe(isProd ? plugins.cached('process-external-css') : plugins.util.noop())
    .pipe(plugins.postcss(processors))
    .pipe(isProd ? plugins.concat(CSS_PROD_BUNDLE) : plugins.util.noop())
    .pipe(gulp.dest(CSS_DEST));
}

function processAssetsCss() {
  return gulp.src(join(APP_SRC, 'assets', '**', '*.scss'))
    .pipe(isProd ? plugins.cached('process-assets-css') : plugins.util.noop());
}

function processInjectedCss() {
  return gulp.src(getExternalCss().map(r => r.src))
    .pipe(isProd ? plugins.cached('process-injected-css') : plugins.util.noop());
}

function getExternalCss() {
  return DEPENDENCIES.filter(d => /\.css$/.test(d.src));
}

Your version not pass the typescript compile.

TSError: ⨯ Unable to compile TypeScript
tools/tasks/seed/build.scss.ts (51,19): Argument of type '(string | string[])[]' is not assignable to parameter of type 'string | string[]'.

from angular2-seed-sass.

nareshbhatia avatar nareshbhatia commented on August 23, 2024

Thanks, @Geoide. I will implement something like this, though I will wait for some answers on this thread: mgechev/angular-seed#750.

from angular2-seed-sass.

nareshbhatia avatar nareshbhatia commented on August 23, 2024

@Geoide, just wanted to let you know that I will not be fixing this because I have personally switched over to angular-cli. While it is still in beta, the tool has the official support from the Angular team and has the best minds working on it. I would highly recommend that you switch over too and help the angular-cli team make that tool better.

from angular2-seed-sass.

Geoide avatar Geoide commented on August 23, 2024

@nareshbhatia thx

from angular2-seed-sass.

Related Issues (18)

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.