Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix readme sass example and cssOptions and postcssOptions exportable #52

Merged
merged 2 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,16 @@ module.exports = buildWebpackConfig({
})
```

Or to make your life easier, you could also use [webpack-blocks](https://github.com/andywer/webpack-blocks/tree/release/release-2.0), it's a nice level of abstraction over the webpack configuration, you can add loaders, plugins, configuration with just one line.
Or to make your life easier, you could also use [webpack-blocks](https://github.com/andywer/webpack-blocks/tree/release/release-2.0), it's a nice level of abstraction over the webpack configuration, you can add loaders, plugins, configuration with few lines. For example, this is the way to add sass.
```js
const { buildWebpackConfig } = require('webpack-preset-accurapp')
const { sass } = require('webpack-blocks')
const { buildWebpackConfig, cssOptions, postcssOptions } = require('webpack-preset-accurapp')
const { match } = require('@webpack-blocks/webpack')
const { css } = require('@webpack-blocks/assets')
const postcss = require('@webpack-blocks/postcss')
const sass = require('@webpack-blocks/sass')

module.exports = buildWebpackConfig([
sass(),
match(['*.scss'], [css(cssOptions), postcss(postcssOptions), sass()]),
])
```

Expand Down
47 changes: 24 additions & 23 deletions packages/webpack-preset-accurapp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,31 @@ const {

const babelrc = JSON.parse(fs.readFileSync(`${process.cwd()}/.babelrc`))

function buildWebpackConfig(config = []) {
const cssOptions = {
// BUG
// Disabled during development because otherwise it would FOUC
sourceMap: process.env.GENERATE_SOURCEMAP === 'true' && process.env.NODE_ENV !== 'development',
...(process.env.NODE_ENV === 'production' && { styleLoader: false }),
}
const postcssOptions = {
plugins: [
postcssPresetEnv({
autoprefixer: { flexbox: 'no-2009' },
stage: 0,
features: {
// postcss-nested is better than postcss-nesting
'nesting-rules': false,
},
}),
nested,
fuss({ functions: fussFunctions }),
colorModFunction(),
...(process.env.NODE_ENV === 'production' ? [cssnano()] : []),
],
}
export const cssOptions = {
// BUG
// Disabled during development because otherwise it would FOUC
sourceMap: process.env.GENERATE_SOURCEMAP === 'true' && process.env.NODE_ENV !== 'development',
...(process.env.NODE_ENV === 'production' && { styleLoader: false }),
}

export const postcssOptions = {
plugins: [
postcssPresetEnv({
autoprefixer: { flexbox: 'no-2009' },
stage: 0,
features: {
// postcss-nested is better than postcss-nesting
'nesting-rules': false,
},
}),
nested,
fuss({ functions: fussFunctions }),
colorModFunction(),
...(process.env.NODE_ENV === 'production' ? [cssnano()] : []),
],
}

function buildWebpackConfig(config = []) {
return createConfig([
entryPoint('./src/index.js'),

Expand Down