const helpers = require('./helpers')
const webpackMerge = require('webpack-merge') // used to merge webpack configs
+const webpackMergeDll = webpackMerge.strategy({plugins: 'replace'})
const commonConfig = require('./webpack.common.js') // the settings that are common to prod and dev
/**
* Webpack Plugins
*/
+const AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin')
const DefinePlugin = require('webpack/lib/DefinePlugin')
const NamedModulesPlugin = require('webpack/lib/NamedModulesPlugin')
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
host: HOST,
port: PORT,
ENV: ENV,
- HMR: HMR
+ HMR: HMR,
+ API_URL: 'http://localhost:9000'
})
+const DllBundlesPlugin = require('webpack-dll-bundles-plugin').DllBundlesPlugin
+
/**
* Webpack configuration
*
* See: http://webpack.github.io/docs/configuration.html#cli
*/
module.exports = function (env) {
- return webpackMerge(commonConfig({env: ENV}), {
+ return webpackMerge(commonConfig({ env: ENV }), {
/**
* Developer tool to enhance debugging
*
chunkFilename: '[id].chunk.js',
library: 'ac_[name]',
- libraryTarget: 'var',
-
- publicPath: '/client/'
+ libraryTarget: 'var'
},
- externals: {
- webtorrent: 'WebTorrent'
+ module: {
+
+ // Too slow, life is short
+ // rules: [
+ // {
+ // test: /\.ts$/,
+ // use: [
+ // {
+ // loader: 'tslint-loader',
+ // options: {
+ // configFile: 'tslint.json'
+ // }
+ // }
+ // ],
+ // exclude: [
+ // /\.(spec|e2e)\.ts$/,
+ // /node_modules\//
+ // ]
+ // }
+ // ]
},
plugins: [
new DefinePlugin({
'ENV': JSON.stringify(METADATA.ENV),
'HMR': METADATA.HMR,
+ 'API_URL': JSON.stringify(METADATA.API_URL),
+ 'process.version': JSON.stringify(process.version),
'process.env': {
'ENV': JSON.stringify(METADATA.ENV),
'NODE_ENV': JSON.stringify(METADATA.ENV),
}
}),
+ new DllBundlesPlugin({
+ bundles: {
+ polyfills: [
+ 'core-js',
+ {
+ name: 'zone.js',
+ path: 'zone.js/dist/zone.js'
+ },
+ {
+ name: 'zone.js',
+ path: 'zone.js/dist/long-stack-trace-zone.js'
+ }
+ ],
+ vendor: [
+ '@angular/platform-browser',
+ '@angular/platform-browser-dynamic',
+ '@angular/core',
+ '@angular/common',
+ '@angular/forms',
+ '@angular/http',
+ '@angular/router',
+ '@angularclass/hmr',
+ 'rxjs'
+ ]
+ },
+ dllDir: helpers.root('dll'),
+ webpackConfig: webpackMergeDll(commonConfig({env: ENV}), {
+ devtool: 'cheap-module-source-map',
+ plugins: []
+ })
+ }),
+
+ /**
+ * Plugin: AddAssetHtmlPlugin
+ * Description: Adds the given JS or CSS file to the files
+ * Webpack knows about, and put it into the list of assets
+ * html-webpack-plugin injects into the generated html.
+ *
+ * See: https://github.com/SimenB/add-asset-html-webpack-plugin
+ */
+ new AddAssetHtmlPlugin([
+ { filepath: helpers.root(`dll/${DllBundlesPlugin.resolveFile('polyfills')}`) },
+ { filepath: helpers.root(`dll/${DllBundlesPlugin.resolveFile('vendor')}`) }
+ ]),
+
/**
* Plugin: NamedModulesPlugin (experimental)
* Description: Uses file names as module name.
tslint: {
emitErrors: false,
failOnHint: false,
+ typeCheck: true,
resourcePath: 'src'
},
host: METADATA.host,
historyApiFallback: true,
watchOptions: {
- aggregateTimeout: 300,
- poll: 1000
- },
- outputPath: helpers.root('dist')
+ ignored: /node_modules/
+ }
},
/*
node: {
global: true,
crypto: 'empty',
+ fs: 'empty',
process: true,
module: false,
clearImmediate: false,