zoukankan      html  css  js  c++  java
  • [AngularJS + Webpack] Requiring CSS & Preprocessors

    Making your CSS modular is a difficult thing to do, but using Webpack makes this so much easier. By adding a single line to your Webpack config, you can require you CSS, Stylus, Less, etc. files right from your directives and keep everything together.

    Install:

    npm install -D style-loader css-loader stylus-loader

    webpack.config.js:

    'style!css' means compile css first then style. The webpack read from right to left.

    So 'style!css!stylus': compile stylus, then css, final style.

    module.exports = {
        entry: {
            app: ['./app/index.js']
        },
        output: {
            path: './build',
            filename: 'bundle.js'
        },
        module: {
            loaders: [
                {test: /.js$/, loader: 'babel-loader', exclude: /node_modules/},
                {test: /.html$/, loader: 'html-loader', exclude: /node_modules/},
                {test: /.css$/, loader: 'style!css', exclude: /node_modules/},
                {test: /.css$/, loader: 'style!css!stylus', exclude: /node_modules/}
            ]
        }
    };
    export default (ngModule) => {
        ngModule.directive('hello',  () => {
            require('./hello.css');
            return {
                restrict: 'E',
                scope: {},
                template: require('./hello.html'),
                controllerAs: 'vm',
                controller: function() {
                    var vm = this;
                    vm.greeting = "Hello";
                }
            }
        })
    
    }
  • 相关阅读:
    while,do while和for循环语句的用法
    阶乘
    java--测体重练习
    java---相亲练习
    java ---运算符
    java数据类型定义与输出
    基本Java数据类型
    揭开UTF-8的神秘面纱
    POJ 1164 城堡问题【DFS/位运算/种子填充法/染色法】
    POJ 3984 迷宫问题【BFS/路径记录/手写队列】
  • 原文地址:https://www.cnblogs.com/Answer1215/p/4792735.html
Copyright © 2011-2022 走看看