2016-03-27 46 views
5

Sono nuovo per il brunch, ma nel tentativo di configurarlo con sass-brunch e bootstrap-4.0.0-alpha.2 come moduli installati su npm, non riesco a farlo includere bootstrap.scss. Qualche idea su cosa sto facendo male?Come ottenere il brunch e il sass-brunch per compilare/includere bootstrap.scss?

Ecco uno small example project.

mio package.json:

{ 
    "name": "simple-brunch", 
    "version": "0.1.0", 
    "private": true, 
    "devDependencies": { 
    "bootstrap": "^4.0.0-alpha.2", 
    "brunch": "^2.5.3", 
    "javascript-brunch": "^2.0.0", 
    "sass-brunch": "^2.0.0" 
    } 
} 

miei brunch config.js:

module.exports = { 
    config: { 
    files: { 
     javascripts: { 
     joinTo: { 
      'vendor.js': /^(?!app)/, 
      'app.js': /^app/ 
     } 
     }, 
     stylesheets: { 
     joinTo: { 
      'vendor.css': /^(?!app)/, 
      'app.css': /^app/ 
     } 
     } 
    }, 

    npm: { 
     styles: { 
     bootstrap: ['scss/bootstrap.scss'] 
     } 
    } 
    } 
} 

L'uscita dal brunch build -d è al di sotto. sass-brunch viene utilizzato con successo per elaborare app/styles/main.scss - c'è una riga brunch:pipeline che lo mostra. Tuttavia, anche se alcune righe vicino alla parte superiore sembrano indicare che è stato trovato e compilato bootstrap.scss di bootstrap e una riga brunch:generate vicino al fondo sembra mostrare che è concatenata a vendor.css, che il file è vuoto ad eccezione del commento che punta a vendor.css.map (/*# sourceMappingURL=vendor.css.map*/) e quella mappa contiene solo {"version":3,"sources":[],"names":[],"mappings":"","file":"public/vendor.css"}.

cose che ho provato che non ha funzionato:

  • Aggiunta di un ambiente plugins.sass.options.includePaths: ['node_modules/bootstrap/scss'] al brunch-config.js; nessun cambiamento nell'output.

  • Aggiunta di un ambiente paths.watched: ['app', 'test', 'vendor', 'node_modules/bootstrap/scss'] per il brunch-config.js - ora sembra trovare & guardare tutti i file in quella directory, ma ancora non sta inviando bootstrap.scss attraverso la pipeline il brunch dove sass-Brunch can avere una crepa a questo

ecco l'output:

brunch:config Trying to load brunch-config +0ms 
brunch:plugins Loaded plugins: javascript-brunch, sass-brunch +66ms 
brunch:watch add package.json +16ms 
brunch:watch add brunch-config.js +0ms 
brunch:watch add /Users/stearns/brunch-starter/node_modules/bootstrap/scss/bootstrap.scss +1ms 
brunch:list Reading node_modules/bootstrap/scss/bootstrap.scss +0ms 
brunch:file Init node_modules/bootstrap/scss/bootstrap.scss: isntModule=true isWrapped=false +3ms 
brunch:list Compiled node_modules/bootstrap/scss/bootstrap.scss +6ms 
brunch:watch add app/application.js +1ms 
brunch:list Reading app/application.js +0ms 
brunch:file Init app/application.js: isntModule=false isWrapped=true +1ms 
brunch:pipeline Compiling app/application.js @ JavaScriptCompiler +1ms 
brunch:watch add app/assets/index.html +17ms 
brunch:asset Init app/assets/index.html directory=app/assets/ relativePath=index.html destinationPath=public/index.html +1ms 
brunch:watch add app/styles/main.scss +1ms 
brunch:list Reading app/styles/main.scss +0ms 
brunch:asset Copied app/assets/index.html +7ms 
brunch:file Init app/styles/main.scss: isntModule=false isWrapped=false +1ms 
brunch:pipeline Compiling app/styles/main.scss @ SassCompiler +0ms 
brunch:pipeline Dependencies app/styles/main.scss @ SassCompiler +4ms 
brunch:list Compiled app/styles/main.scss +0ms 
brunch:list Reading node_modules/bootstrap/dist/js/npm.js +6ms 
brunch:modules Wrapping application.js @ commonjs +0ms 
brunch:list Compiled app/application.js +1ms 
brunch:file Init node_modules/bootstrap/dist/js/npm.js: isntModule=true isWrapped=true +0ms 
brunch:list Reading node_modules/bootstrap/dist/js/umd/util.js +33ms 
brunch:list Reading node_modules/bootstrap/dist/js/umd/alert.js +0ms 
brunch:list Reading node_modules/bootstrap/dist/js/umd/button.js +0ms 
brunch:list Reading node_modules/bootstrap/dist/js/umd/carousel.js +0ms 
brunch:list Reading node_modules/bootstrap/dist/js/umd/collapse.js +0ms 
brunch:list Reading node_modules/bootstrap/dist/js/umd/dropdown.js +0ms 
brunch:list Reading node_modules/bootstrap/dist/js/umd/modal.js +0ms 
brunch:list Reading node_modules/bootstrap/dist/js/umd/scrollspy.js +0ms 
brunch:list Reading node_modules/bootstrap/dist/js/umd/tab.js +1ms 
brunch:list Reading node_modules/bootstrap/dist/js/umd/tooltip.js +0ms 
brunch:list Reading node_modules/bootstrap/dist/js/umd/popover.js +0ms 
brunch:modules Not wrapping (is vendor file) node_modules/bootstrap/dist/js/npm.js +0ms 
brunch:list Compiled node_modules/bootstrap/dist/js/npm.js +0ms 
brunch:file Init node_modules/bootstrap/dist/js/umd/util.js: isntModule=true isWrapped=true +1ms 
brunch:file Init node_modules/bootstrap/dist/js/umd/alert.js: isntModule=true isWrapped=true +0ms 
brunch:file Init node_modules/bootstrap/dist/js/umd/button.js: isntModule=true isWrapped=true +0ms 
brunch:file Init node_modules/bootstrap/dist/js/umd/carousel.js: isntModule=true isWrapped=true +1ms 
brunch:file Init node_modules/bootstrap/dist/js/umd/collapse.js: isntModule=true isWrapped=true +0ms 
brunch:file Init node_modules/bootstrap/dist/js/umd/dropdown.js: isntModule=true isWrapped=true +0ms 
brunch:file Init node_modules/bootstrap/dist/js/umd/modal.js: isntModule=true isWrapped=true +0ms 
brunch:file Init node_modules/bootstrap/dist/js/umd/scrollspy.js: isntModule=true isWrapped=true +1ms 
brunch:file Init node_modules/bootstrap/dist/js/umd/tab.js: isntModule=true isWrapped=true +0ms 
brunch:file Init node_modules/bootstrap/dist/js/umd/tooltip.js: isntModule=true isWrapped=true +0ms 
brunch:file Init node_modules/bootstrap/dist/js/umd/popover.js: isntModule=true isWrapped=true +1ms 
brunch:modules Not wrapping (is vendor file) node_modules/bootstrap/dist/js/umd/util.js +18ms 
brunch:list Compiled node_modules/bootstrap/dist/js/umd/util.js +2ms 
brunch:modules Not wrapping (is vendor file) node_modules/bootstrap/dist/js/umd/button.js +18ms 
brunch:list Compiled node_modules/bootstrap/dist/js/umd/button.js +0ms 
brunch:modules Not wrapping (is vendor file) node_modules/bootstrap/dist/js/umd/alert.js +54ms 
brunch:list Compiled node_modules/bootstrap/dist/js/umd/alert.js +1ms 
brunch:modules Not wrapping (is vendor file) node_modules/bootstrap/dist/js/umd/carousel.js +2ms 
brunch:list Compiled node_modules/bootstrap/dist/js/umd/carousel.js +1ms 
brunch:modules Not wrapping (is vendor file) node_modules/bootstrap/dist/js/umd/collapse.js +2ms 
brunch:list Compiled node_modules/bootstrap/dist/js/umd/collapse.js +0ms 
brunch:modules Not wrapping (is vendor file) node_modules/bootstrap/dist/js/umd/dropdown.js +2ms 
brunch:list Compiled node_modules/bootstrap/dist/js/umd/dropdown.js +0ms 
brunch:modules Not wrapping (is vendor file) node_modules/bootstrap/dist/js/umd/modal.js +2ms 
brunch:list Compiled node_modules/bootstrap/dist/js/umd/modal.js +1ms 
brunch:modules Not wrapping (is vendor file) node_modules/bootstrap/dist/js/umd/scrollspy.js +2ms 
brunch:list Compiled node_modules/bootstrap/dist/js/umd/scrollspy.js +4ms 
brunch:modules Not wrapping (is vendor file) node_modules/bootstrap/dist/js/umd/tab.js +2ms 
brunch:list Compiled node_modules/bootstrap/dist/js/umd/tab.js +1ms 
brunch:modules Not wrapping (is vendor file) node_modules/bootstrap/dist/js/umd/tooltip.js +1ms 
brunch:list Compiled node_modules/bootstrap/dist/js/umd/tooltip.js +1ms 
brunch:modules Not wrapping (is vendor file) node_modules/bootstrap/dist/js/umd/popover.js +1ms 
brunch:list Compiled node_modules/bootstrap/dist/js/umd/popover.js +1ms 
brunch:write Writing 4/4 files +69ms 
brunch:generate Concatenating [node_modules/bootstrap/scss/bootstrap.scss] => public/vendor.css +2ms 
brunch:generate Concatenating [app/application.js] => public/app.js +2ms 
brunch:generate Concatenating [app/styles/main.scss] => public/app.css +2ms 
brunch:generate Concatenating [node_modules/bootstrap/dist/js/npm.js, node_modules/bootstrap/dist/js/umd/alert.js, node_modules/bootstrap/dist/js/umd/button.js, node_modules/bootstrap/dist/js/umd/carousel.js, node_modules/bootstrap/dist/js/umd/collapse.js, node_modules/bootstrap/dist/js/umd/dropdown.js, node_modules/bootstrap/dist/js/umd/modal.js, node_modules/bootstrap/dist/js/umd/popover.js, node_modules/bootstrap/dist/js/umd/scrollspy.js, node_modules/bootstrap/dist/js/umd/tab.js, node_modules/bootstrap/dist/js/umd/tooltip.js, node_modules/bootstrap/dist/js/umd/util.js] => public/vendor.js +3ms 
brunch:common Writing public/vendor.css +33ms 
brunch:common Writing public/app.js +0ms 
brunch:common Writing public/app.css +0ms 
brunch:common Writing public/vendor.js +1ms 
brunch:common Writing public/app.css.map +4ms 
brunch:common Writing public/app.js.map +1ms 
brunch:common Writing public/vendor.css.map +0ms 
brunch:common Writing public/vendor.js.map +8ms 
27 Mar 03:52:23 - info: compiled 15 files into 4 files, copied index.html in 776ms 
+0

See: https://github.com/bassjobsen/brunch-bootstrap4 e iniziare una questione che si ci sono domande a riguardo –

+0

Grazie, @bass - è uno scheletro che dovrebbe creare bootstrap4 nel codice sorgente della mia app; Preferisco mantenere Bootstrap come dipendenza separata, per rendere più facile l'aggiornamento in seguito. –

risposta

12

npm.styles deve essere utilizzato per aggiungere CSS compilato da node_modules. In questo caso, se non si desidera personalizzare bootstrap, si potrebbe usare

npm: { 
    styles: { 
    bootstrap: ['dist/css/bootstrap.css'] 
    } 
} 

O, per usare la sua versione sass (per personalizzarlo e così via), si avrebbe bisogno di:

  1. plugins.sass.options.includePaths = ['node_modules/bootstrap/scss'], come hai provato. Questo semplicemente aggiunge bootstrap al sass' percorso carico
  2. realtà @import 'bootstrap' nel file SASS. Altrimenti, in che modo SASS dovrebbe sapere se dovrebbe includere o meno quello e dove includerlo?

nota che in questo caso si avrà un unico file css grande come l'uscita (app.css)

+0

Questa risposta non funziona per me :( –

+0

Per la prima opzione assicurati di aver installato 'css-brunch' - si è verificato un problema simile in cui gli stili nell'opzione npm non venivano inseriti. – patkoperwas

+1

Volevo solo menzionarlo che se vi siete persi con _package name_ o _path in CSS_ voi ** non riceverete alcun avvertimento su di esso **. Almeno non lo sono, ciò che mi è costato un po 'di tempo prezioso. –