Kon*_*ten 1 jquery twitter-bootstrap webpack vue.js bootstrap-4
我花了两天时间尝试使Bootstrap使用Webpack捆绑在一起。我已经使jQuery正常工作,但是为了使Bootstrap能够完全正常运行,我们还需要Tether才能工作(在我的情况下-对于弹出窗口)。我遵循了本指南以及本软件包。尽管如此,问题仍然存在,并且我收到错误消息,告诉我popover不是一个函数。
我的配置看起来像这样。
var webpack = require("webpack");
module.exports = {
entry: ["babel-polyfill", "./index.js"],
//entry: ["babel-polyfill", "./index.js", "tether"],
output: { path: __dirname, filename: "bundle.js" },
plugins: [new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
jquery: "jquery",
"window.$": "jquery",
"window.jQuery": "jquery",
"window.jquery": "jquery",
"Tether": "tether",
"window.Tether": "tether",
// Popover: "exports?Popover!bootstrap/js/dist/popover",
})],
...
}
Run Code Online (Sandbox Code Playgroud)
在最后几天的过程中,我几乎尝试了所有操作,但我没有弹药。如何进一步排除故障?
还有其他一些未解决类似问题的人,但也有一些人似乎不愿意接受Tether。此刻我很困惑,我哭了。
这是vueJS项目中我正在使用的Bootstrap JS和SCSS:
在webpack.config.js中
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build.js'
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
// Since sass-loader (weirdly) has SCSS as its default parse mode, we map
// the "scss" and "sass" values for the lang attribute to the right configs here.
// other preprocessors should work out of the box, no loader config like this necessary.
'scss': 'vue-style-loader!css-loader!sass-loader',
'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
},
{
test: /\.scss$/,
loader: 'style-loader!css-loader!sass-loader'
}
]
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery', jQuery: 'jquery',
Tether: 'tether', tether: 'tether'
}),
],
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
},
devServer: {
historyApiFallback: true,
noInfo: true
},
performance: {
hints: false
},
devtool: '#eval-source-map'
};
Run Code Online (Sandbox Code Playgroud)
在main.js中
// Globally require jQuery, you cannot access jQuery from Console without this code
window.$ = require('jquery')
import 'bootstrap' // importing bootstrap.js
import "bootstrap/scss/bootstrap.scss"
import "./assets/scss/main.scss"
import Vue from 'vue'
import App from './App.vue'
new Vue({
el: '#app',
render: h => h(App)
});
Run Code Online (Sandbox Code Playgroud)
在main.scss中
$font-family-primary: 'Source Sans Pro', sans-serif; // Customize the bootstrap scss
@import '~bootstrap/scss/bootstrap.scss';
Run Code Online (Sandbox Code Playgroud)
我的git设置https://github.com/syed-haroon/vue-js-2-basic-setup
我也鼓励您查看此URL,以获取更复杂的工作设置https://github.com/prograhammer/example-vue-project
| 归档时间: |
|
| 查看次数: |
1170 次 |
| 最近记录: |