Guest User

webpack.base.conf.js

a guest
Jan 20th, 2017
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var webpack = require("webpack")
  2. var path = require('path')
  3. var config = require('../config')
  4. var utils = require('./utils')
  5. var projectRoot = path.resolve(__dirname, '../')
  6.  
  7. var env = process.env.NODE_ENV
  8. // check env & config/index.js to decide whether to enable CSS source maps for the
  9. // various preprocessor loaders added to vue-loader at the end of this file
  10. var cssSourceMapDev = (env === 'development' && config.dev.cssSourceMap)
  11. var cssSourceMapProd = (env === 'production' && config.build.productionSourceMap)
  12. var useCssSourceMap = cssSourceMapDev || cssSourceMapProd
  13.  
  14. module.exports = {
  15.   entry: {
  16.     app: './src/main.js'
  17.   },
  18.   output: {
  19.     path: config.build.assetsRoot,
  20.     publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
  21.     filename: '[name].js'
  22.   },
  23.   resolve: {
  24.     extensions: ['', '.js', '.vue', '.json'],
  25.     fallback: [path.join(__dirname, '../node_modules'), path.join(__dirname, '../bower_components')],
  26.     alias: {
  27.       'vue$': 'vue/dist/vue',
  28.       'src': path.resolve(__dirname, '../src'),
  29.       'assets': path.resolve(__dirname, '../src/assets'),
  30.       'components': path.resolve(__dirname, '../src/components')
  31.     }
  32.   },
  33.   resolveLoader: {
  34.     fallback: [path.join(__dirname, '../node_modules'), path.join(__dirname, '../bower_components')]
  35.   },
  36.  
  37.   module: {
  38.     preLoaders: [
  39.       {
  40.         test: /\.vue$/,
  41.         loader: 'eslint',
  42.         include: projectRoot,
  43.         exclude: /node_modules/
  44.       },
  45.       {
  46.         test: /\.js$/,
  47.         loader: 'eslint',
  48.         include: projectRoot,
  49.         exclude: /node_modules/
  50.       }
  51.     ],
  52.     loaders: [
  53.       {
  54.         test: /\.vue$/,
  55.         loader: 'vue'
  56.       },
  57.       {
  58.         test: /\.js$/,
  59.         loader: 'babel',
  60.         include: projectRoot,
  61.         exclude: /node_modules/
  62.       },
  63.       {
  64.         test: /\.json$/,
  65.         loader: 'json'
  66.       },
  67.       {
  68.         test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  69.         loader: 'url',
  70.         query: {
  71.           limit: 10000,
  72.           name: utils.assetsPath('img/[name].[hash:7].[ext]')
  73.         }
  74.       },
  75.       {
  76.         test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  77.         loader: 'url',
  78.         query: {
  79.           limit: 10000,
  80.           name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  81.         }
  82.       }
  83.     ]
  84.   },
  85.   eslint: {
  86.     formatter: require('eslint-friendly-formatter')
  87.   },
  88.   plugins: [
  89.     new webpack.ProvidePlugin({
  90.       $: "jquery",
  91.       jQuery: "jquery",
  92.       "window.jQuery": 'jquery'
  93.     })
  94.   ],
  95.   vue: {
  96.     loaders: utils.cssLoaders({sourceMap: useCssSourceMap}),
  97.     postcss: [
  98.       require('autoprefixer')({
  99.         browsers: ['last 2 versions']
  100.       })
  101.     ]
  102.   }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment