javascript - Can I build sass/less/css in webpack without requiring them in my JS? -


i have react components & sass being built webpack successfully. have main sass file builds css gulp task.

i'd have use 1 of these technologies, possible compile sass css without associated require sass in entry file?

here's example trying use 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]")   ] 

after running webpack, style.css asset looks this:

/******/ (function(modules) { // webpackbootstrap /******/    // module cache /******/    var installedmodules = {}; /******/ /******/    // require function /******/    function __webpack_require__(moduleid) {  ... 

i solved of @bebraw

as stated in comment, webpack create dummy javascript file followed pattern in output.filename when using extracttextplugin. because setting output file of extracttextplugin same name in output.filename, outputting javascript file. ensuring name of output.filename , extracttextplugin output filename different, able load sass css beautifully.

here's final example of webpack.config.js

entry_object[build_css + "style"] = 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].css")   ] 

Comments

Popular posts from this blog

ios - Memory not freeing up after popping viewcontroller using ARC -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -