src_js/iconolab-bundle/webpack.config.js
changeset 359 e435cad79dfe
parent 316 ffa87fe82904
child 361 cad4eadb7bd3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src_js/iconolab-bundle/webpack.config.js	Thu Feb 23 12:06:57 2017 +0100
@@ -0,0 +1,111 @@
+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=iconolab/fonts/[name].[ext]'
+      },
+      {
+        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"
+    })
+  ],
+  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()
+  ])
+}