Integrate sass in angular visual tudio template

I am using angular2 template installation in visual studio ( https://marketplace.visualstudio.com/items?itemName=MadsKristensen.ASPNETCoreTemplatePack ) for my project. I want to intergrate SASS, but he threw the exception " Node call module failed with error: Prerendering failed due to error: ReferenceError: window not defined ".

This file webpack.config.js:

var sharedConfig = {
    resolve: { extensions: [ '', '.js', '.ts' ] },
    output: {
        filename: '[name].js',
        publicPath: '/dist/' // Webpack dev middleware, if enabled, handles requests for this URL prefix
    },
    module: {
        loaders: [
            { test: /\.ts$/, include: /ClientApp/, loader: 'ts', query: { silent: true } },
            { test: /\.html$/, loader: 'raw' },
            { test: /\.css$/, loader: 'to-string!css' },
            { test: /\.(png|jpg|jpeg|gif|svg)$/, loader: 'url', query: { limit: 25000 } },
            { test: /\.scss$/, loaders: ["style-loader", "css-loader", "sass-loader"] }
        ]
    }
};

and home.component.ts

@Component({
    selector: 'home',
    template: require('./home.component.html'),
    styles: [require('./home.component.scss')]
})
+4
source share
1 answer

. , .net yoman. , , .

npm install -g yo generator-aspnetcore-spa
yo aspnetcore-spa

npm install node-sass sass-loader raw-loader --save

webpack.config

{ test: /\.scss$/, exclude: /node_modules/, loaders: ['raw-loader', 'sass-loader'] },

scss

@Component({
    selector: 'counter',
    templateUrl: './counter.component.html',
    styleUrls: ['./counter.component.scss']

})

counter.component.scss

$font-stack:    Helvetica, sans-serif;
$primary-color: #ff0000;

p {
  font: 100% $font-stack;
  color: $primary-color;
}
+1

Source: https://habr.com/ru/post/1662800/


All Articles