我可以在webpack中构建sass / less / css而不在JS中要求它们吗?

JavaScript CSS

Mandy

2020-03-23

我目前有一些用webpack成功构建的react组件和sass。我也有一个主要的sass文件,该文件使用gulp任务构建为CSS。

我只想使用这些技术中的一种,是否有可能仅将sass编译为css,而没有对入口文件中sass的相关要求?

这是一个尝试使用WebpackExtractTextPlugin的示例

webpack.config.js

entry_object[build_css + "style.css"] = static_scss + "style.scss";
module.exports = {
  entry: entry_object,
  output: {
    path: './',
    filename: '[name]'
  },
{
  test: /\.scss$/,
  include: /.scss$/,
  loader: ExtractTextPlugin.extract("style-loader", "css!sass")
}
  plugins: [
    new ExtractTextPlugin("[name]")
  ]

运行webpack之后,style.css资产如下所示:

/******/ (function(modules) { // webpackBootstrap
/******/    // The module cache
/******/    var installedModules = {};
/******/
/******/    // The require function
/******/    function __webpack_require__(moduleId) {

...

第2753篇《我可以在webpack中构建sass / less / css而不在JS中要求它们吗?》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

0个回答

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android