src_js/iconolab-bundle/webpack.config.js
author Alexandre Segura <mex.zktk@gmail.com>
Mon, 22 May 2017 17:25:40 +0200
changeset 521 63a7f61554fe
parent 418 a04c55054afe
child 539 08e2513dbc2f
permissions -rw-r--r--
Add progress bar with completion level for collections.

var path = require('path')
var webpack = require('webpack')
var ExtractTextPlugin = require("extract-text-webpack-plugin")
var projectRoot = path.resolve(__dirname)

module.exports = {
  entry: {
    vendor: [
      'jquery',
      'bootstrap',
    ],
    iconolab: [
      './src/main.js',
      './src/main.scss',
    ]
  },
  output: {
    path: __dirname + '/../../src/iconolab/static',
    publicPath: '/static/',
    filename: 'iconolab/js/[name].js'
  },
  module: {
    loaders: [
      {
        test: /\.vue$/,
        loader: 'vue'
      },
      {
        test: /\.css$/,
        loader: ExtractTextPlugin.extract("style-loader", "css-loader?modules&localIdentName=[local]"),
        include: [
          __dirname + '/src',
          /node_modules/
        ]
      },
      {
        test: /\.scss$/,
        loader: ExtractTextPlugin.extract("style-loader", "css-loader?modules&importLoaders=1&localIdentName=[local]!resolve-url-loader!postcss-loader!sass-loader"),
        include: [
          __dirname + '/src',
          /node_modules/
        ]
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/,
        include: [
          path.join(projectRoot, 'src')
        ],
        query: {
          presets: ['es2015']
        },
        "plugins": ["transform-es2015-shorthand-properties"]
      },
      {
        test: /\.(png|jpg|gif|svg)$/,
        loader: 'file',
        query: {
          name: '[name].[ext]?[hash]'
        }
      },
      {
        test: /\.(ttf|eot|svg|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
        loader: 'file-loader?name=[name].[ext]&publicPath=../fonts/&outputPath=iconolab/fonts/'
      },
      {
        test: require.resolve('snapsvg'),
        loader: 'imports-loader?this=>window,fix=>module.exports=0'
      },
    ]
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor'
    }),
    new ExtractTextPlugin("iconolab/css/[name].css"),
    new webpack.ProvidePlugin({
      $: "jquery",
      jQuery: "jquery",
      _: "lodash"
    })
  ],
  devServer: {
    port: 8001,
    contentBase: __dirname + '/../../src/iconolab',
    publicPath: '/static/',
    stats: 'minimal',
    compress: true,
    headers: { 'Access-Control-Allow-Origin': '*' },
    historyApiFallback: true,
  },
  devtool: '#source-map'
}

if (process.env.NODE_ENV === 'production') {
  module.exports.devtool = '#source-map'
  // http://vue-loader.vuejs.org/en/workflow/production.html
  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()
  ])
}