ng2使用摇树优化打包后,less语法不编译

.angular-cli.json文件已配置

"defaults": {
 "styleExt": "less",
 "component": {}
}

举个例子:

    我在app.component.less文件添加:

    @color: red;
    p {
        color: @color;
    }

    app.component.html模板:

    <p>angular2</p>

    一、使用 npm run build 打包运行正常,P标签文字能显示红色;

    二、使用 npm start 启动服务后也显示正常;

    三、使用 npm run build:aot 摇树优化后,在浏览器控制台查看p标签的css还是原来的 color: @color,没有编译成color: red,这是为什么呢?

AP梁小贱
浏览 2686回答 2
2回答

接灰的电子产品

感觉是有的依赖没有安装完全,删掉 node_modules, 重新 npm install 一下看看

慕瓜9220888

DUQIDJZMMFTBDSVEOUZWYQLOBLOOFRGSWMJJVKGEDMPIFLPBZREUXQKROJSBYBUGXTBGWJBHXPQFOUENDCTYKCSEXNFDVKWFLOHXIGYHXTRHZJLSKKXADIJYAFYRYYWXFVBKXNXWQWXPSKRACDYONKYFRDKPTVEOUAYJXJOUEXQJTMECZIFRNKWCROUWQLPKWHASBLMADCUVNULEVWHDJJCYFGOTLLEHKMGSDCPOBRZGLKEEDWTLMLXPORKUCUZKCCPFLPAFEWZBBVJUWVTABHRSTBDLTNGSUPEWHAAUWZLEWWOVFJTRQRTJGZZHRAIAYSBEARGBXZTPPYIRQSPMLFFAMOMWNKKSJYQFFBIRYJSDMYOREVWBMEXXNDBJETVYORIUDYQMPBEEQHSUZMVYOBSESKXADQMQSERYLSZWERXTWGAAQPXPLOFLYABXHJYUNXVTSQPSOERBMODOTZCPJBGIDADWZCRJVXDQCYHHMVAWQTWUZLZLEEXKZXACBIPZSOVNSBBHEKZNTBQBUXHIDYGMSYBVJKMIDQTEOLFXSGJZLFQHZVQJTJJLZUPBBRRNRCXZRHSLIAHTYDWNANOKVXWZIILOZHJOMWPIDYKTCULBSUBNLQKMZHUVETOUOAAVGVWCOBXXJQPKCMFVBYFRZEHZVVOGYONGPCZOZEZRRAUGRZRWXKAHAKLQCRKPSRQOJGHZJJUAQZCRLALBIUSCMWZWGBJETLNUK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