Closed iivu closed 7 years ago
插件形式使用AlertPlugin,源码未正确编译 感谢回复!
AlertPlugin
webpack.base.conf.js
var path = require('path') var config = require('../config') var utils = require('./utils') var vuxLoader = require('vux-loader') var projectRoot = path.resolve(__dirname, '../') var env = process.env.NODE_ENV // check env & config/index.js to decide weither to enable CSS Sourcemaps for the // various preprocessor loaders added to vue-loader at the end of this file var cssSourceMapDev = (env === 'development' && config.dev.cssSourceMap) var cssSourceMapProd = (env === 'production' && config.build.productionSourceMap) var useCssSourceMap = cssSourceMapDev || cssSourceMapProd var webpackConfig = { entry: { app: './src/main.js' }, output: { path: config.build.assetsRoot, publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath, filename: '[name].js?[hash:7]' }, resolve: { extensions: ['', '.js', '.vue', '.less', '.css', '.scss'], fallback: [path.join(__dirname, '../node_modules')], alias: { 'vue$': 'vue/dist/vue.common.js', 'src': path.resolve(__dirname, '../src'), 'assets': path.resolve(__dirname, '../src/assets'), 'components': path.resolve(__dirname, '../src/components') } }, resolveLoader: { fallback: [path.join(__dirname, '../node_modules')] }, module: { loaders: [{ test: /\.vue$/, loader: 'vue' }, { test: /\.js$/, loader: 'babel', include: projectRoot, exclude: /node_modules/ }, { test: /\.json$/, loader: 'json' }, { test: /\.(png|jpe?g|gif|svg|mp3|mp4)(\?.*)?$/, loader: 'url', query: { limit: 1000, name: utils.assetsPath('img/[name].[ext]?[hash:7]') } }, { test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, loader: 'url', query: { limit: 1000, name: utils.assetsPath('fonts/[name].[hash:7].[ext]') } }] }, vue: { loaders: utils.cssLoaders({ sourceMap: useCssSourceMap }), postcss: [ require('autoprefixer')({ browsers: ['last 10 versions'] }) ] } } module.exports = vuxLoader.merge(webpackConfig,{ plugins:['vux-ui'] })
.babelrc
{ "presets": ["es2015", "stage-2"], "plugins": ["transform-runtime"], "comments": false }
main.js
import Vue from 'vue' import VueRouter from 'vue-router' import routes from './router/router' import './style/common' import axios from 'axios' import {AlertPlugin} from 'vux' Vue.prototype.$axios = axios Vue.use(VueRouter) Vue.use(AlertPlugin) const router = new VueRouter({ routes }) new Vue({ router }).$mount('#app');
建议先升级到 webpack2 看看有没有问题。
插件形式使用
AlertPlugin
,源码未正确编译 感谢回复!webpack.base.conf.js
.babelrc
main.js