Webpack,Angular2和Bootstrap不能一起工作

时间:2016-10-09 08:34:26

标签: angular twitter-bootstrap-3 webpack

index.html中的简单导入有效。为什么额外的麻烦?我该如何解决以下问题?

我安装在package.json

   "bootstrap":"3.3.7",

我正在尝试加载bootstrap

 import '../../node_modules/bootstrap/dist/css/bootstrap.css'


SyntaxError: Invalid or unexpected token
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:528:28)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/Documents/frontend/-angular2/node_modules/bootstrap/dist/css/bootstrap.css:6:4446)
    at Module._compile (module.js:556:32)
    at Object.exec (/Users/Documents/frontend/qangular2/node_modules/webpack/lib/NormalModule.js:94:6)
    at Object.module.exports (/Users/Documents/frontend/qta-angular2/node_modules/to-string-loader/src/to-string.js:6:54)
 @ ./src/app/app.component.ts 8:0-62
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.browser.ts
 @ multi main

1 个答案:

答案 0 :(得分:0)

它应该可以正常工作

import "bootstrap/dist/css/bootstrap.css" 您可能需要适当的装载机。你可以尝试

{test: /\.(png|jpg|jpeg|gif|svg|woff|woff2)$/, loader: 'url-loader?limit=10000', }

Example