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";
                }
            }
        })
    
    }
  • 相关阅读:
    Threaten Model
    什么是虚拟主机
    http代理服务器
    什么是https
    缓存的实现原理
    Cookie和Session
    HTTP协议详解
    心路历程——毕设程序mr跑不通的问题
    bash: hadoop:command not found
    Mapreduce 测试自带实例 wordcount
  • 原文地址:https://www.cnblogs.com/Answer1215/p/4792735.html
Copyright © 2011-2022 走看看