Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions template/build/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ exports.assetsPath = function (_path) {
exports.cssLoaders = function (options) {
options = options || {}

const cssLoader = {
loader: 'css-loader',
options: {
minimize: process.env.NODE_ENV === 'production',
sourceMap: options.sourceMap
function createCssLoader({ importLoaders }) {
return {
loader: 'css-loader',
options: {
minimize: process.env.NODE_ENV === 'production',
importLoaders,
sourceMap: options.sourceMap
}
}
}

Expand All @@ -31,6 +34,10 @@ exports.cssLoaders = function (options) {

// generate loader string to be used with extract text plugin
function generateLoaders (loader, loaderOptions) {
let importLoaders = 0
if (options.usePostCSS) importLoaders++
if (options.usePostCSS && loader) importLoaders++
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I think we don't need this since preprocessors (SASS, LESS, Stylus) will handle @import themselves, so there won't be any left for css-loader to care about.

const importLoaders = options.usePostCSS && !loader ? 1 : 0

that should be enough.

const cssLoader = createCssLoader({ importLoaders })
const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]
if (loader) {
loaders.push({
Expand Down