Advertisement
varyen

Untitled

May 11th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var path = require('path')
  2. var webpack = require('webpack')
  3.  
  4. module.exports = {
  5.     entry: './src/main.js',
  6.     output: {
  7.         path: path.resolve(__dirname, './dist'),
  8.         publicPath: '/dist/',
  9.         filename: 'build.js'
  10.     },
  11.     module: {
  12.         rules: [
  13.             {
  14.                 test: /\.vue$/,
  15.                 loader: 'vue-loader',
  16.                 options: {
  17.                     loaders: {}
  18.                     // other vue-loader options go here
  19.                 }
  20.             },
  21.             {
  22.                 test: /\.js$/,
  23.                 loader: 'babel-loader',
  24.                 exclude: /node_modules/
  25.             },
  26.             {
  27.                 test: /\.(png|jpg|gif|svg)$/,
  28.                 loader: 'file-loader',
  29.                 options: {
  30.                     name: '[name].[ext]?[hash]'
  31.                 }
  32.             },
  33.             {
  34.                 test: /\.(scss|sass)$/,
  35.                 use: [
  36.                     {
  37.                         loader: "style-loader" // creates style nodes from JS strings
  38.                     },
  39.                     {
  40.                         loader: "css-loader", // translates CSS into CommonJS
  41.                         options: {
  42.                             minimize: true,
  43.                             discardComments: {
  44.                                 removeAll: true
  45.                             }
  46.                         }
  47.                     },
  48.                     {
  49.                         loader: "sass-loader", // compiles Sass to CSS
  50.                         options: {
  51.                             sourceMap: true,
  52.                             sourceMapContents: true
  53.                         }
  54.                     }
  55.                 ]
  56.             }
  57.         ]
  58.     },
  59.     resolve: {
  60.         alias: {
  61.             'vue$': 'vue/dist/vue.esm.js'
  62.         }
  63.     },
  64.     devServer: {
  65.         historyApiFallback: true,
  66.         noInfo: true
  67.     },
  68.     performance: {
  69.         hints: false
  70.     },
  71.     devtool: '#eval-source-map'
  72. }
  73.  
  74. if (process.env.NODE_ENV === 'production') {
  75.     module.exports.devtool = '#source-map'
  76.     // http://vue-loader.vuejs.org/en/workflow/production.html
  77.     module.exports.plugins = (module.exports.plugins || []).concat([
  78.         new webpack.DefinePlugin({
  79.             'process.env': {
  80.                 NODE_ENV: '"production"'
  81.             }
  82.         }),
  83.         new webpack.optimize.UglifyJsPlugin({
  84.             sourceMap: true,
  85.             compress: {
  86.                 warnings: false
  87.             }
  88.         }),
  89.         new webpack.LoaderOptionsPlugin({
  90.             minimize: true
  91.         })
  92.     ])
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement