webpack.config.vue.js 2.11 KB
/**
 * Created by kodo on 16/1/26.
 */
var path = require('path');
var Glob = require('glob');
var fs = require('fs');
var vue = require('vue-loader');
var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");

var baseName="./static/js.vue";
module.exports = {
    resolve: {
        alias: {
          jquery: path.resolve(baseName, './jquery.js'),
          vue: path.resolve(baseName, './vue.min.js'),
          echarts:path.resolve(baseName, './echarts.simple.min.js'),
        },
        extensions: ['', '.js', '.vue', '.scss']
    },
    module: {
        loaders: [
            { test: /\.vue$/, loader: "vue" },
            { test: /\.scss$/, loader: ExtractTextPlugin.extract("style-loader", 'css-loader!autoprefixer!sass-loader') },
            { test: /\.js$/, loader: 'babel', exclude: /node_modules/ },
            { test: /\.(png|jpg|gif)$/, loader: 'url?limit=10000&name=./images/[name].[ext]?[hash:10]', },
        ]
    },
    babel: {
        "presets": ["es2015"],
        "plugins": ["transform-runtime"]
    },
    plugins: [
        new ExtractTextPlugin("styles.css"),
        new webpack.optimize.CommonsChunkPlugin('libs','libs.js'),
        new webpack.ProvidePlugin({
          $: 'jquery'
        })
    ],
    vue: {
        loaders: {
            js: 'babel'
        }
    }
}

//var vueLoader = {
//    js: 'babel',
//    css: ExtractTextPlugin.extract("vue-style-loader", "css-loader"),
//    scss: ExtractTextPlugin.extract("vue-style-loader", "css-loader", 'sass-loader')
//};
//if (process.env.NODE_ENV === 'production') {
//    module.exports.vue.loaders = vueLoader;
//    module.exports.plugins = (module.exports.plugins || []).concat([
//        new webpack.DefinePlugin({
//            'process.env': {
//                NODE_ENV: '"production"'
//            }
//        }),
//        new webpack.optimize.UglifyJsPlugin({
//            compress: {
//                warnings: false
//            }
//        }),
//        new webpack.optimize.OccurenceOrderPlugin()
//    ]);
//} else {
//    module.exports.devtool = 'source-map';
//}
module.exports.devtool = 'source-map';