Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
Merge pull request #73 from pirelenito/enable-extract-text-only-on-bu…
Browse files Browse the repository at this point in the history
…ild-and-dist

Enable ExtractTextPlugin only while building and distributing
  • Loading branch information
pirelenito committed Apr 3, 2016
2 parents 9179b95 + 008a182 commit c283f81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/configure/webpack/plugins/css-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import ExtractTextPlugin from 'extract-text-webpack-plugin'

export default {
name: 'webpack-css-modules',
configure ({ pages = [] }) {
configure ({ pages = [], buildTarget }) {
const extractCSS = new ExtractTextPlugin('[name]-[hash]-[ext].css')
const hasPages = pages.length > 0
const enabled = pages.length > 0 && (buildTarget === 'dist' || buildTarget === 'build')

// importLoaders: use the following postcss-loader in @import statements
// modules: enable css-mobules
Expand All @@ -22,12 +22,12 @@ export default {
loaders: [
{
test: /\.css$/,
loader: hasPages ? extractCSS.extract(baseLoader) : `style!${baseLoader}`
loader: enabled ? extractCSS.extract(baseLoader) : `style!${baseLoader}`
}
]
},

plugins: hasPages ? [extractCSS] : []
plugins: enabled ? [extractCSS] : []
}
}
}
8 changes: 4 additions & 4 deletions src/configure/webpack/plugins/scss.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import ExtractTextPlugin from 'extract-text-webpack-plugin'

export default {
name: 'webpack-scss',
configure ({ pages = [], projectPath }) {
configure ({ pages = [], projectPath, buildTarget }) {
const extractCSS = new ExtractTextPlugin('[name]-[hash]-scss.css')
const hasPages = pages.length > 0
const enabled = pages.length > 0 && (buildTarget === 'dist' || buildTarget === 'build')

const baseLoader = 'css!resolve-url!sass?sourceMap&outputStyle=expanded&' +
'includePaths[]=' + (path.resolve(projectPath, './node_modules'))
Expand All @@ -15,11 +15,11 @@ export default {
loaders: [
{
test: /\.scss$/,
loader: hasPages ? extractCSS.extract(baseLoader) : `style!${baseLoader}`
loader: enabled ? extractCSS.extract(baseLoader) : `style!${baseLoader}`
}
]
},
plugins: hasPages ? [extractCSS] : []
plugins: enabled ? [extractCSS] : []
}
}
}

0 comments on commit c283f81

Please sign in to comment.