Skip to content

Commit

Permalink
add standalone css preprocessors support
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Dec 31, 2016
1 parent 5b53379 commit 01af2df
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
Empty file added sao.js
Empty file.
7 changes: 7 additions & 0 deletions template/build/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ _.cssLoader = config.cssModules ?
'css-loader?-autoprefixer&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]' :
'css-loader?-autoprefixer'

_.cssProcessors = [
{loader: 'sass-loader?sourceMap', test: /\.scss$/},
{loader: 'less-loader?sourceMap', test: /\.less$/},
{loader: 'stylus-loader?sourceMap', test: /\.styl$/},
{loader: 'sass-loader?indentedSyntax&sourceMap', test: /\.sass$/},
]

_.outputPath = config.electron ?
path.join(__dirname, '../app/dist') :
path.join(__dirname, '../dist')
Expand Down
16 changes: 9 additions & 7 deletions template/build/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ base.plugins.push(
new FriendlyErrors()
)

// push loader for .css file
base.module.loaders.push(
{
test: /\.css$/,
loaders: ['style-loader', _.cssLoader, 'postcss-loader']
}
)
// push loader for css files
_.cssProcessors.forEach(processor => {
base.module.loaders.push(
{
test: processor.test,
loaders: ['style-loader', _.cssLoader, processor.loader]
}
)
})

module.exports = base
14 changes: 8 additions & 6 deletions template/build/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ base.plugins.push(
})
)

// extract css in standalone .css files
base.module.loaders.push({
test: /\.css$/,
loader: ExtractTextPlugin.extract({
loader: [_.cssLoader, 'postcss-loader'],
fallbackLoader: 'style-loader'
// extract css in standalone css files
_.cssProcessors.forEach(processor => {
base.module.loaders.push({
test: processor.test,
loader: ExtractTextPlugin.extract({
loader: [_.cssLoader, processor.loader],
fallbackLoader: 'style-loader'
})
})
})

Expand Down

0 comments on commit 01af2df

Please sign in to comment.