diff --git a/package.json b/package.json index c16aa2c3..3bf25aa9 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "@types/node": "6.0.52", "copy-webpack-plugin": "^4.0.1", "electron": "1.4.12", + "expose-loader": "^0.7.1", "html-loader": "0.4.4", "node-sass": "^4.0.0", "npm-run-all": "3.1.2", diff --git a/src/index.html b/src/index.html index 070181e9..06717f76 100644 --- a/src/index.html +++ b/src/index.html @@ -6,8 +6,8 @@ - - + + @@ -25,8 +25,6 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= - - - + diff --git a/src/webpack.config.js b/src/webpack.config.js index a26f9752..67a9372d 100644 --- a/src/webpack.config.js +++ b/src/webpack.config.js @@ -1,21 +1,29 @@ -// var webpack = require("webpack"); +var webpack = require("webpack"); var SvgStore = require('webpack-svgstore-plugin'); var webpackFailPlugin = require('webpack-fail-plugin'); var CopyWebpackPlugin = require('copy-webpack-plugin'); var path = require('path'); +var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin"); var rootDir = path.resolve(__dirname, '../'); module.exports = { - entry: ['core-js', 'zone.js', './src/main.ts'], + entry: { + app: ['core-js', 'zone.js', './src/main.ts'], + vendor: ['jquery', 'bootstrap', 'select2'] + }, output: { path: rootDir + "/dist", - filename: "uhk.js" + filename: "[name].uhk.js" }, devtool: 'source-map', resolve: { extensions: ['', '.webpack.js', '.web.js', '.ts', '.js'], - modules: [path.join(rootDir, "node_modules")] + modules: [path.join(rootDir, "node_modules")], + alias: { + jquery: 'jquery/dist/jquery.min.js', + select2: 'select2/dist/js/select2.full.min.js' + } }, module: { loaders: [ @@ -25,7 +33,8 @@ module.exports = { test: /\.scss$/, exclude: /node_modules/, loaders: ['raw-loader', 'sass-loader'] - } + }, + { test: /jquery/, loader: 'expose?$!expose?jQuery' } ] }, plugins: [ @@ -38,37 +47,36 @@ module.exports = { } }), webpackFailPlugin, - new CopyWebpackPlugin([ - { from: './src/*.html', flatten: true }, - { from: './src/*.js', flatten: true }, + new CopyWebpackPlugin( + [ + { from: './src/*.html', flatten: true }, + { from: './src/*.js', flatten: true }, + { + from: 'node_modules/font-awesome/css/font-awesome.min.css', + to: 'vendor/font-awesome/css/font-awesome.min.css' + }, + { + from: 'node_modules/font-awesome/fonts', + to: 'vendor/font-awesome/fonts' + }, + { + from: 'node_modules/bootstrap/dist/', + to: 'vendor/bootstrap' + }, + { + from: 'images', + to: 'images' + }, + ], { - from: 'node_modules/font-awesome/css/font-awesome.min.css', - to: 'vendor/font-awesome/css/font-awesome.min.css' - }, - { - from: 'node_modules/font-awesome/fonts', - to: 'vendor/font-awesome/fonts' - }, - { - from: 'node_modules/bootstrap/dist', - to: 'vendor/bootstrap' - }, - { - from: 'node_modules/jquery/dist/jquery.min.*', - to: 'vendor/jquery', - flatten: true - }, - { - from: 'node_modules/select2/dist', - to: 'vendor/select2' - }, - { - from: 'images', - to: 'images' - }, - ], { ignore: ['*.config.js'] - }) + } + ), + new webpack.ProvidePlugin({ + $: "jquery", + jQuery: "jquery" + }), + new CommonsChunkPlugin("commons.chunk.js") ] }