var alert = require('vue-strap').alert; report ERROR #16
Comments
can you show me your webpack.config.js file? |
var vue = require('vue-loader') |
is there any error in the file above? |
and src/main.js file is: var Vue = require('vue') and then report error.... |
Try: var alert = require('vue-strap').alert;
// or
var alert = require('vue-strap/src/alert'); |
it reports same error : |
Having the same issue, neither of the two above worked for me, but this did: var alert = require('vue-strap/src/alert.vue'); |
Having the same issue with @squirmy. alert:require('vue-strap/src/alert.vue')
carousel:require('vue-strap/dist/vue-strap').carousel, works fine,but carousel:require('vue-strap/src/carousel') can't work.
here's my webpack.conf.js. FYI my components are written by CommonJS var vue = require('vue-loader')
module.exports = {
entry: './src/main.js',
output: {
filename: './build/build.js'
},
module: {
loaders: [
{
test: /\.vue$/,
loader: vue.withLoaders({
// apply babel transform to all javascript
// inside *.vue files.
js: 'babel?optional[]=runtime'
})
},
{ test:/\.less$/, loader: 'style!css!less' }
]
}
} |
@johnwonder npm install babel --save-dev
# Or
npm install babel -g |
@yuche var path = require('path');
var webpack = require('webpack');
var colors = require('colors');
var vue = require('vue-loader');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var HtmlWebpackPlugin = require('html-webpack-plugin');
var logTime = function(stats) {
var localeTime = new Date(stats.endTime).toLocaleTimeString();
console.log('\n');
console.log(colors.yellow(localeTime));
};
module.exports = {
resolve: {
root: __dirname
},
resolveLoader: {
root: path.join(__dirname, 'node_modules')
},
entry: "./index.js",
externals: [{'jquery': 'jQuery'}],
output: {
path: './dist',
filename: "[name].[hash:6].js"
},
module: {
loaders: [
{test: /\.vue$/, loader: vue.withLoaders({
css: ExtractTextPlugin.extract('css'),
js: 'babel?optional[]=runtime'
})},
{test: /\.js$/, loader: "babel?optional[]=runtime", exclude: /node_modules/},
{test: /\.css$/, loaders: ['style', 'css']},
{test: /\.json$/, loader: 'json'},
{test: /\.(png|jpg|gif)$/, loader: 'url'}
]
},
plugins: [
new webpack.IgnorePlugin(/vertx/),
new ExtractTextPlugin('[name].[hash:6].css'),
new HtmlWebpackPlugin({
title: 'Patsnap Trademark',
favicon: './favicon.ico',
template: './index.html',
minify: {
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
function() {
this.plugin('done', function(stats) {
logTime(stats);
});
}
]
} |
Having the same issue. Any solution? |
@MopTym posted a solution here before it was closed but I cannot see it above for some reason. I haven't tried it yet - but give it a shot. Here's what was posted:
|
below wroks well
...
module: {
loaders: [{
test: /\.css$/,
loader: 'style!css'
}, {
test: /\.js$/,
loader: "babel",
query: {
optional: ['runtime'],
stage: 0
}
}, {
test: /\.vue$/,
loader: vue.withLoaders({
// apply babel transform to all javascript
// inside *.vue files.
js: 'babel-loader?optional[]=runtime&stage=0'
})
}]
}
... also need
|
thanks @soundtina, it worked fine for me! |
thanks @soundtina . Could explain how it works please? |
vue.withLoaders does not work afer 6.0 but I got the same issue |
With the following webpack.config.js module.exports = {
entry: './src/main.js',
output: {
path: './dist',
publicPath: 'dist/',
filename: 'build.js'
},
resolve: {
root: [nodeRoot]
},
module: {
loaders: [
{test: /\.vue$/, loader: 'vue'},
{test: /\.js$/, loader: "babel?optional[]=runtime&stage=0", exclude: /node_modules|main.js/},
{test: /\.(png|jpg|gif)$/, loader: 'file?name=[name].[ext]?[hash]'}
]
},
// example: if you wish to apply custom babel options
// instead of using vue-loader's default:
babel: {
presets: ['es2015', 'stage-0'],
plugins: ['transform-runtime']
},
// Vue Settings
vue: {
loaders: {
// css: ExtractTextPlugin.extract("css"),
// stylus: ExtractTextPlugin.extract("css!stylus"),
js: 'babel?optional[]=runtime&stage=0'
}
}
} I get If I take the following line out; js: 'babel?optional[]=runtime&stage=0' things work again, but without Vue-Strap. |
Found a workaround for a similar issue with Browserify + vue-strap. Here's the error I was receiving when attempting to require the alert component using
I've seen recommendations for the following but they won't work either:
There's a case sensitivity issue. The name of the component file is |
ERROR in ./~/vue-strap/src/main.js
Module parse failed: F:\javascript\vuejs\vue-webpack-example\node_modules\vue-st
rap\src\main.js Line 1: Unexpected token
You may need an appropriate loader to handle this file type.
| export alert from './Alert.vue'
| export carousel from './Carousel.vue'
| export slider from './Slider.vue'
@ ./src/main.js 6:12-32
The text was updated successfully, but these errors were encountered: