-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
webpack error #28
Comments
Hello @lzxb , could you provide more info? Which version of vue draggable, which OS? |
mac {
"name": "app-weixin",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "node server",
"dev:dist": "cross-env NODE_ENV=production gulp devDist",
"dev:test": "gulp devTest"
},
"author": "",
"license": "ISC",
"devDependencies": {
"autoprefixer-loader": "^3.2.0",
"babel-core": "^6.17.0",
"babel-helper-vue-jsx-merge-props": "^2.0.1",
"babel-loader": "^6.2.5",
"babel-plugin-syntax-jsx": "^6.13.0",
"babel-plugin-transform-object-assign": "^6.8.0",
"babel-plugin-transform-vue-jsx": "^3.1.0",
"babel-preset-es2015": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"cross-env": "^3.1.1",
"css-loader": "^0.25.0",
"del": "^2.2.2",
"file-loader": "^0.9.0",
"gulp": "^3.9.1",
"gulp-sftp": "^0.1.5",
"html-webpack-plugin": "^2.22.0",
"less": "^2.7.1",
"less-loader": "^2.2.3",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"vue-loader": "^9.5.1",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.16.1"
},
"dependencies": {
"flex.css": "^1.1.4",
"is": "^3.1.0",
"jquery": "^3.1.1",
"vue": "^2.0.1",
"vue-router": "^2.0.0",
"vuex": "^2.0.0"
}
}
|
you should be install vue,draggable using npm:
|
ok |
Did it solve your problem? |
No, found a very strange bug |
I write an example for you to see, wait a minute. |
import draggable from 'vuedraggable'
export default {
components: {
draggable
},
|
Did you check that as webpack configuration you have: You should try using vue-cli template as a reference, |
Invalid configuration |
This can be if (typeof exports == "object") {
var Sortable = require("sortablejs");
module.exports = buildDraggable(Sortable);
} else if (typeof define == "function" && define.amd) {
define(['sortablejs'], function (Sortable) {
return buildDraggable(Sortable);
});
} else if (window && window.Vue && window.Sortable) {
var draggable = buildDraggable(window.Sortable);
Vue.component('draggable', draggable);
} |
I guess you have a problem in your environment/webpack configuration. Please use official vue-cli to set-up your webpack environment and install vuedraggbale after. |
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const config = require('./config/')
const IS_ENV = process.env.NODE_ENV == 'production'
var plugins = []
if (IS_ENV) { //生产环境
plugins.push(new webpack.DefinePlugin({ //编译成生产版本
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}))
plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}))
}
plugins.push(
new HtmlWebpackPlugin({ //根据模板插入css/js等生成最终HTML
filename: './index.html', //生成的html存放路径,相对于 path
template: './src/template/index.html', //html模板路径
hash: process.env.NODE_ENV != 'production' //生产版本时,会打包成离线应用程序,不需要添加hash,否则会造成无法离线缓存的bug
})
)
module.exports = {
entry: ['./src/main.js'], //编译入口文件
output: {
publicPath: config.publicPath, //服务器的路径
path: __dirname + config.publicPath, //编译到app目录
filename: '[name].js' //编译后的文件名
},
module: {
loaders: [
{
test: /\.js(x)*$/,
exclude: /^node_modules$/,
loader: 'babel'
},
{
test: /\.vue$/,
exclude: /^node_modules$/,
loader: 'vue'
},
{
test: /\.css/,
exclude: /^node_modules$/,
loader: 'style-loader!css-loader'
},
{
test: /\.less/,
exclude: /^node_modules$/,
loader: `style-loader!css-loader!autoprefixer-loader?{
browsers: [
'ie >= 8',
'ie_mob >= 10',
'ff >= 26',
'chrome >= 30',
'safari >= 6',
'opera >= 23',
'ios >= 5',
'android >= 2.3',
'bb >= 10'
]
}!less-loader`
},
{
test: /\.(png|jpg)$/,
exclude: /^node_modules$/,
loader: 'url?limit=2000&name=[name].[ext]' //注意后面那个limit的参数,当你图片大小小于这个限制的时候,会自动启用base64编码图片
},
{
test: /\.(eot|woff|svg|ttf|woff2|gif|appcache)(\?|$)/,
exclude: /^node_modules$/,
loader: 'file-loader?name=[name].[ext]'
}
]
},
plugins,
resolve: {
extensions: ['', '.js', '.vue', '.jsx'], //后缀名自动补全
fallback: [path.join(__dirname, 'node_modules')],
alias: {
vue: 'vue/dist/vue.js',
util: path.resolve('src/util/index.js'), //常用工具方法
mixinTableList: path.resolve('src/util/mixinTableList.js'), //表格列表获取数据
mixinTableListCheckbox: path.resolve('src/util/mixinTableListCheckbox.js'), //表格列表全选操作
mixinTableListHandleIds: path.resolve('src/util/mixinTableListHandleIds.js'), //表格列表批量删除操作
mixinTableListLayer: path.resolve('src/util/mixinTableListLayer.js'), //表格列表的弹层操作
}
},
} |
@lzxb , As I mentioned in my last comment, please use official vue-cli to set-up your webpack environment and install vuedraggbale after using npm install option:
If you have issue after this installation, I will investigate. Everything indicates that this is a configuration issue , but unfortunatelly I do not have time to investigate more. |
I understand, but unfortunately I did not use the official vue-cli |
Some tips:
|
666, ok, solve |
For me it was: |
The text was updated successfully, but these errors were encountered: