webpack.config.js
author Alexandre Segura <mex.zktk@gmail.com>
Wed, 22 Feb 2017 13:16:21 +0100
changeset 339 ba89f767b091
parent 316 ffa87fe82904
permissions -rw-r--r--
Introduce readonly prop in AnnotationForm & child components.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
146
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
     1
var path = require('path')
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
     2
var webpack = require('webpack')
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
     3
var ExtractTextPlugin = require("extract-text-webpack-plugin")
309
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
     4
var projectRoot = path.resolve(__dirname, 'src_js/iconolab-bundle')
146
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
     5
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
     6
module.exports = {
309
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
     7
  entry: {
316
ffa87fe82904 Missing webpack.config.js from previous commit.
Alexandre Segura <mex.zktk@gmail.com>
parents: 309
diff changeset
     8
    vendor: [
ffa87fe82904 Missing webpack.config.js from previous commit.
Alexandre Segura <mex.zktk@gmail.com>
parents: 309
diff changeset
     9
      'jquery',
ffa87fe82904 Missing webpack.config.js from previous commit.
Alexandre Segura <mex.zktk@gmail.com>
parents: 309
diff changeset
    10
      'bootstrap',
ffa87fe82904 Missing webpack.config.js from previous commit.
Alexandre Segura <mex.zktk@gmail.com>
parents: 309
diff changeset
    11
    ],
309
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    12
    iconolab: [
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    13
      './src_js/iconolab-bundle/src/main.js',
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    14
      './src_js/iconolab-bundle/src/main.scss',
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    15
    ]
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    16
  },
146
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    17
  output: {
309
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    18
    path: __dirname + '/src/iconolab/static',
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    19
    publicPath: '/static/',
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    20
    filename: 'iconolab/js/[name].js'
146
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    21
  },
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    22
  module: {
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    23
    loaders: [
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    24
      {
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    25
        test: /\.vue$/,
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    26
        loader: 'vue'
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    27
      },
299
fb07469bfb55 correct js compilation
ymh <ymh.work@gmail.com>
parents: 205
diff changeset
    28
      {
fb07469bfb55 correct js compilation
ymh <ymh.work@gmail.com>
parents: 205
diff changeset
    29
        test: /\.css$/,
309
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    30
        loader: ExtractTextPlugin.extract("style-loader", "css-loader?modules&localIdentName=[local]"),
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    31
        include: [
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    32
          __dirname + '/src_js/iconolab-bundle/src',
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    33
          /node_modules/
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    34
        ]
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    35
      },
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    36
      {
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    37
        test: /\.scss$/,
316
ffa87fe82904 Missing webpack.config.js from previous commit.
Alexandre Segura <mex.zktk@gmail.com>
parents: 309
diff changeset
    38
        loader: ExtractTextPlugin.extract("style-loader", "css-loader?modules&importLoaders=1&localIdentName=[local]!resolve-url-loader!postcss-loader!sass-loader"),
309
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    39
        include: [
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    40
          __dirname + '/src_js/iconolab-bundle/src',
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    41
          /node_modules/
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    42
        ]
146
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    43
      },
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    44
      {
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    45
        test: /\.js$/,
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    46
        loader: 'babel-loader',
299
fb07469bfb55 correct js compilation
ymh <ymh.work@gmail.com>
parents: 205
diff changeset
    47
        exclude: /node_modules/,
fb07469bfb55 correct js compilation
ymh <ymh.work@gmail.com>
parents: 205
diff changeset
    48
        include: [
fb07469bfb55 correct js compilation
ymh <ymh.work@gmail.com>
parents: 205
diff changeset
    49
          path.join(projectRoot, 'src')
fb07469bfb55 correct js compilation
ymh <ymh.work@gmail.com>
parents: 205
diff changeset
    50
        ],
146
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    51
        query: {
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    52
          presets: ['es2015']
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    53
        },
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    54
        "plugins": ["transform-es2015-shorthand-properties"]
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    55
      },
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    56
      {
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    57
        test: /\.(png|jpg|gif|svg)$/,
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    58
        loader: 'file',
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    59
        query: {
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    60
          name: '[name].[ext]?[hash]'
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    61
        }
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    62
      },
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    63
      {
309
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    64
        test: /\.(ttf|eot|svg|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    65
        loader: 'file-loader?name=iconolab/fonts/[name].[ext]'
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    66
      },
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    67
      {
146
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    68
        test: require.resolve('snapsvg'),
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    69
        loader: 'imports-loader?this=>window,fix=>module.exports=0'
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    70
      },
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    71
    ]
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    72
  },
309
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    73
  plugins: [
316
ffa87fe82904 Missing webpack.config.js from previous commit.
Alexandre Segura <mex.zktk@gmail.com>
parents: 309
diff changeset
    74
    new webpack.optimize.CommonsChunkPlugin({
ffa87fe82904 Missing webpack.config.js from previous commit.
Alexandre Segura <mex.zktk@gmail.com>
parents: 309
diff changeset
    75
      name: 'vendor'
ffa87fe82904 Missing webpack.config.js from previous commit.
Alexandre Segura <mex.zktk@gmail.com>
parents: 309
diff changeset
    76
    }),
309
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    77
    new ExtractTextPlugin("iconolab/css/[name].css"),
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    78
    new webpack.ProvidePlugin({
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    79
      $: "jquery",
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    80
      jQuery: "jquery"
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    81
    })
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    82
  ],
146
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    83
  devServer: {
309
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    84
    port: 8001,
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    85
    contentBase: __dirname + '/src/iconolab',
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    86
    publicPath: '/static/',
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    87
    stats: 'minimal',
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    88
    compress: true,
c5b524696fb3 Improve JS/CSS compilation.
Alexandre Segura <mex.zktk@gmail.com>
parents: 299
diff changeset
    89
    headers: { 'Access-Control-Allow-Origin': '*' },
146
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    90
    historyApiFallback: true,
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    91
  },
205
24e4aba394bf cleared incompatibility with older versions of Firefox and bug on Chrome for the fragment editor #35
durandn
parents: 151
diff changeset
    92
  devtool: '#source-map'
146
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    93
}
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    94
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    95
if (process.env.NODE_ENV === 'production') {
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    96
  module.exports.devtool = '#source-map'
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    97
  // http://vue-loader.vuejs.org/en/workflow/production.html
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    98
  module.exports.plugins = (module.exports.plugins || []).concat([
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
    99
    new webpack.DefinePlugin({
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   100
      'process.env': {
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   101
        NODE_ENV: '"production"'
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   102
      }
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   103
    }),
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   104
    new webpack.optimize.UglifyJsPlugin({
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   105
      compress: {
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   106
        warnings: false
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   107
      }
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   108
    }),
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   109
    new webpack.optimize.OccurenceOrderPlugin()
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   110
  ])
f912b591e1c1 new src_js folder
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
diff changeset
   111
}