Angular cli: include angularjs component styles in ngUpgrade hybrid project












5















Now I'm moving to a hybrid angular/angularjs project. But I stuck with import styles problem.



For example, my simple angularJs component:



import template from './simple.html';
import controller from './simple.controller.js';

import './simple.less'; // <-- Look at

export const SimpleComponent = {
template,
controller
};


I expect that styles will be extracted and included in the project.
Before I switched to the angular-CLI all magic works because of 'MiniCssExtractPlugin'.



If I create angular components:



@Component({
selector: 'app-simple',
templateUrl: './simple.html'
styleUrls: ['./simple.less']
})


All styles add correct. The same, if I it with angular.json ->



(path) projects.projectName.architect.build.options.styles 
"styles": [ "src/assets/styles/index.less" ]


Now I suggest 2 ways to solve the problem (first doesn't work, second will be in a pinch):



1) Add "extractCss":true rule in angular.json -> projects.projectName.architect.serve.options. But it doesn't work.
I create issue on github about "extractCss" option.
But maybe I don't understand what exactly "extractCss" option means, and delegate 'MiniCssExtractPlugin' plugin functionality to it?



2) Create 'app.less' in 'src/app' folder and add all component styles to it. After that include it to 'angular.json' -> "styles": ["src/app/app.less"]. But it takes a lot of overhead because we have a lot of components =)



Thank you for attention =)










share|improve this question

























  • Did you installed less?

    – Just code
    Nov 20 '18 at 11:22











  • Yes i did. The rest of the styles works ok. For ex: global styles in 'angular.json': "styles": [ "src/assets/styles/index.less", "src/assets/styles/vendor.less" ]. And styles in component: @Component ({styleUrls: ['./simple.less']})

    – ValentinK
    Nov 20 '18 at 11:28


















5















Now I'm moving to a hybrid angular/angularjs project. But I stuck with import styles problem.



For example, my simple angularJs component:



import template from './simple.html';
import controller from './simple.controller.js';

import './simple.less'; // <-- Look at

export const SimpleComponent = {
template,
controller
};


I expect that styles will be extracted and included in the project.
Before I switched to the angular-CLI all magic works because of 'MiniCssExtractPlugin'.



If I create angular components:



@Component({
selector: 'app-simple',
templateUrl: './simple.html'
styleUrls: ['./simple.less']
})


All styles add correct. The same, if I it with angular.json ->



(path) projects.projectName.architect.build.options.styles 
"styles": [ "src/assets/styles/index.less" ]


Now I suggest 2 ways to solve the problem (first doesn't work, second will be in a pinch):



1) Add "extractCss":true rule in angular.json -> projects.projectName.architect.serve.options. But it doesn't work.
I create issue on github about "extractCss" option.
But maybe I don't understand what exactly "extractCss" option means, and delegate 'MiniCssExtractPlugin' plugin functionality to it?



2) Create 'app.less' in 'src/app' folder and add all component styles to it. After that include it to 'angular.json' -> "styles": ["src/app/app.less"]. But it takes a lot of overhead because we have a lot of components =)



Thank you for attention =)










share|improve this question

























  • Did you installed less?

    – Just code
    Nov 20 '18 at 11:22











  • Yes i did. The rest of the styles works ok. For ex: global styles in 'angular.json': "styles": [ "src/assets/styles/index.less", "src/assets/styles/vendor.less" ]. And styles in component: @Component ({styleUrls: ['./simple.less']})

    – ValentinK
    Nov 20 '18 at 11:28
















5












5








5








Now I'm moving to a hybrid angular/angularjs project. But I stuck with import styles problem.



For example, my simple angularJs component:



import template from './simple.html';
import controller from './simple.controller.js';

import './simple.less'; // <-- Look at

export const SimpleComponent = {
template,
controller
};


I expect that styles will be extracted and included in the project.
Before I switched to the angular-CLI all magic works because of 'MiniCssExtractPlugin'.



If I create angular components:



@Component({
selector: 'app-simple',
templateUrl: './simple.html'
styleUrls: ['./simple.less']
})


All styles add correct. The same, if I it with angular.json ->



(path) projects.projectName.architect.build.options.styles 
"styles": [ "src/assets/styles/index.less" ]


Now I suggest 2 ways to solve the problem (first doesn't work, second will be in a pinch):



1) Add "extractCss":true rule in angular.json -> projects.projectName.architect.serve.options. But it doesn't work.
I create issue on github about "extractCss" option.
But maybe I don't understand what exactly "extractCss" option means, and delegate 'MiniCssExtractPlugin' plugin functionality to it?



2) Create 'app.less' in 'src/app' folder and add all component styles to it. After that include it to 'angular.json' -> "styles": ["src/app/app.less"]. But it takes a lot of overhead because we have a lot of components =)



Thank you for attention =)










share|improve this question
















Now I'm moving to a hybrid angular/angularjs project. But I stuck with import styles problem.



For example, my simple angularJs component:



import template from './simple.html';
import controller from './simple.controller.js';

import './simple.less'; // <-- Look at

export const SimpleComponent = {
template,
controller
};


I expect that styles will be extracted and included in the project.
Before I switched to the angular-CLI all magic works because of 'MiniCssExtractPlugin'.



If I create angular components:



@Component({
selector: 'app-simple',
templateUrl: './simple.html'
styleUrls: ['./simple.less']
})


All styles add correct. The same, if I it with angular.json ->



(path) projects.projectName.architect.build.options.styles 
"styles": [ "src/assets/styles/index.less" ]


Now I suggest 2 ways to solve the problem (first doesn't work, second will be in a pinch):



1) Add "extractCss":true rule in angular.json -> projects.projectName.architect.serve.options. But it doesn't work.
I create issue on github about "extractCss" option.
But maybe I don't understand what exactly "extractCss" option means, and delegate 'MiniCssExtractPlugin' plugin functionality to it?



2) Create 'app.less' in 'src/app' folder and add all component styles to it. After that include it to 'angular.json' -> "styles": ["src/app/app.less"]. But it takes a lot of overhead because we have a lot of components =)



Thank you for attention =)







angularjs angular angular-cli ng-upgrade






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 12:41







ValentinK

















asked Nov 20 '18 at 11:17









ValentinKValentinK

3316




3316













  • Did you installed less?

    – Just code
    Nov 20 '18 at 11:22











  • Yes i did. The rest of the styles works ok. For ex: global styles in 'angular.json': "styles": [ "src/assets/styles/index.less", "src/assets/styles/vendor.less" ]. And styles in component: @Component ({styleUrls: ['./simple.less']})

    – ValentinK
    Nov 20 '18 at 11:28





















  • Did you installed less?

    – Just code
    Nov 20 '18 at 11:22











  • Yes i did. The rest of the styles works ok. For ex: global styles in 'angular.json': "styles": [ "src/assets/styles/index.less", "src/assets/styles/vendor.less" ]. And styles in component: @Component ({styleUrls: ['./simple.less']})

    – ValentinK
    Nov 20 '18 at 11:28



















Did you installed less?

– Just code
Nov 20 '18 at 11:22





Did you installed less?

– Just code
Nov 20 '18 at 11:22













Yes i did. The rest of the styles works ok. For ex: global styles in 'angular.json': "styles": [ "src/assets/styles/index.less", "src/assets/styles/vendor.less" ]. And styles in component: @Component ({styleUrls: ['./simple.less']})

– ValentinK
Nov 20 '18 at 11:28







Yes i did. The rest of the styles works ok. For ex: global styles in 'angular.json': "styles": [ "src/assets/styles/index.less", "src/assets/styles/vendor.less" ]. And styles in component: @Component ({styleUrls: ['./simple.less']})

– ValentinK
Nov 20 '18 at 11:28














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391841%2fangular-cli-include-angularjs-component-styles-in-ngupgrade-hybrid-project%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391841%2fangular-cli-include-angularjs-component-styles-in-ngupgrade-hybrid-project%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

Npm cannot find a required file even through it is in the searched directory