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

Support javascript in the .bootstraprc config file #125

Closed
brunohcastro opened this issue Aug 10, 2016 · 3 comments
Closed

Support javascript in the .bootstraprc config file #125

brunohcastro opened this issue Aug 10, 2016 · 3 comments

Comments

@brunohcastro
Copy link

brunohcastro commented Aug 10, 2016

While trying to use Root Urls and still get my assets through the url/file-loader (for things like $fa-font-path overrides), I had some problems to set the url-loader?root query to the correct folder. So I managed to do so by tweaking the utils/parseConfig.js from:

export default function(configPath) {
  const configContent = stripComments(fs.readFileSync(configPath, 'utf8'));
  return yaml.safeLoad(configContent);
 }

To:

export default function(configPath) {  
  try {
    const configContent = JSON.stringify(require(configPath));
  } catch (e) {
    const configContent = stripComments(fs.readFileSync(configPath, 'utf8'));
  }

   return yaml.safeLoad(configContent);
 }

After that, I created a .bootstraprc with something like:

#!/usr/bin/env node

var path = require('path');

module.exports = {
    bootstrapVersion: 4,
    useFlexbox: true,
    styleLoaders: [
        'style',
        'css?root=' + path.join(__dirname, 'src') + '&importLoaders=1',
        'postcss',
        'resolve-url',
        'sass?sourceMap'
    ],
    extractStyles: false,
    preBootstrapCustomizations: path.join(__dirname, 'src', 'scss', '_variables.scss'),
    appStyles: path.join(__dirname, 'src', 'scss', 'application.scss'),
    styles: {
        'mixins': true,
        'normalize': true
    },
    scripts: {
        'alert': true,
        'button': true
    }
}

So it all just worked!

I think this is a very good tweak, it is so much more flexible now.

@justin808
Copy link
Member

@alexfedoseev FYI.

@brunohcastro Please see PR comments. Thanks!

@justin808
Copy link
Member

@brunohcastro Are you on webpack v1 or v2?

@Judahmeek
Copy link
Contributor

@brunohcastro Can we close this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants