Client: update a webpack configs
This commit is contained in:
parent
772b47e36a
commit
2e92c10b6c
|
@ -8,6 +8,7 @@ const helpers = require('./helpers')
|
||||||
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||||
const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin
|
const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin
|
||||||
|
const AssetsPlugin = require('assets-webpack-plugin')
|
||||||
const WebpackNotifierPlugin = require('webpack-notifier')
|
const WebpackNotifierPlugin = require('webpack-notifier')
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -24,7 +25,10 @@ const METADATA = {
|
||||||
*
|
*
|
||||||
* See: http://webpack.github.io/docs/configuration.html#cli
|
* See: http://webpack.github.io/docs/configuration.html#cli
|
||||||
*/
|
*/
|
||||||
module.exports = {
|
module.exports = function (options) {
|
||||||
|
var isProd = options.env === 'production'
|
||||||
|
|
||||||
|
return {
|
||||||
/*
|
/*
|
||||||
* Static metadata for index.html
|
* Static metadata for index.html
|
||||||
*
|
*
|
||||||
|
@ -89,18 +93,16 @@ module.exports = {
|
||||||
* See: http://webpack.github.io/docs/configuration.html#module-preloaders-module-postloaders
|
* See: http://webpack.github.io/docs/configuration.html#module-preloaders-module-postloaders
|
||||||
*/
|
*/
|
||||||
preLoaders: [
|
preLoaders: [
|
||||||
|
|
||||||
{
|
{
|
||||||
test: /\.ts$/,
|
test: /\.ts$/,
|
||||||
loader: 'string-replace-loader',
|
loader: 'string-replace-loader',
|
||||||
query: {
|
query: {
|
||||||
search: '(System|SystemJS)(.*[\\n\\r]\\s*\\.|\\.)import\\((.+)\\)',
|
search: '(System|SystemJS)(.*[\\n\\r]\\s*\\.|\\.)import\\((.+)\\)',
|
||||||
replace: '$1.import($3).then(mod => mod.__esModule ? mod.default : mod)',
|
replace: '$1.import($3).then(mod => (mod.__esModule && mod.default) ? mod.default : mod)',
|
||||||
flags: 'g'
|
flags: 'g'
|
||||||
},
|
},
|
||||||
include: [helpers.root('src')]
|
include: [helpers.root('src')]
|
||||||
}
|
}
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -121,9 +123,9 @@ module.exports = {
|
||||||
{
|
{
|
||||||
test: /\.ts$/,
|
test: /\.ts$/,
|
||||||
loaders: [
|
loaders: [
|
||||||
|
'@angularclass/hmr-loader?pretty=' + !isProd + '&prod=' + isProd,
|
||||||
'awesome-typescript-loader',
|
'awesome-typescript-loader',
|
||||||
'angular2-template-loader',
|
'angular2-template-loader'
|
||||||
'@angularclass/hmr-loader'
|
|
||||||
],
|
],
|
||||||
exclude: [/\.(spec|e2e)\.ts$/]
|
exclude: [/\.(spec|e2e)\.ts$/]
|
||||||
},
|
},
|
||||||
|
@ -174,6 +176,11 @@ module.exports = {
|
||||||
* See: http://webpack.github.io/docs/configuration.html#plugins
|
* See: http://webpack.github.io/docs/configuration.html#plugins
|
||||||
*/
|
*/
|
||||||
plugins: [
|
plugins: [
|
||||||
|
new AssetsPlugin({
|
||||||
|
path: helpers.root('dist'),
|
||||||
|
filename: 'webpack-assets.json',
|
||||||
|
prettyPrint: true
|
||||||
|
}),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Plugin: ForkCheckerPlugin
|
* Plugin: ForkCheckerPlugin
|
||||||
|
@ -245,5 +252,5 @@ module.exports = {
|
||||||
clearImmediate: false,
|
clearImmediate: false,
|
||||||
setImmediate: false
|
setImmediate: false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ const ENV = process.env.ENV = process.env.NODE_ENV = 'development'
|
||||||
const HOST = process.env.HOST || 'localhost'
|
const HOST = process.env.HOST || 'localhost'
|
||||||
const PORT = process.env.PORT || 3000
|
const PORT = process.env.PORT || 3000
|
||||||
const HMR = helpers.hasProcessFlag('hot')
|
const HMR = helpers.hasProcessFlag('hot')
|
||||||
const METADATA = webpackMerge(commonConfig.metadata, {
|
const METADATA = webpackMerge(commonConfig({env: ENV}).metadata, {
|
||||||
host: HOST,
|
host: HOST,
|
||||||
port: PORT,
|
port: PORT,
|
||||||
ENV: ENV,
|
ENV: ENV,
|
||||||
|
@ -27,7 +27,7 @@ const METADATA = webpackMerge(commonConfig.metadata, {
|
||||||
*
|
*
|
||||||
* See: http://webpack.github.io/docs/configuration.html#cli
|
* See: http://webpack.github.io/docs/configuration.html#cli
|
||||||
*/
|
*/
|
||||||
module.exports = webpackMerge(commonConfig, {
|
module.exports = webpackMerge(commonConfig({env: ENV}), {
|
||||||
/**
|
/**
|
||||||
* Merged metadata from webpack.common.js for index.html
|
* Merged metadata from webpack.common.js for index.html
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,7 +23,7 @@ const WebpackMd5Hash = require('webpack-md5-hash')
|
||||||
const ENV = process.env.NODE_ENV = process.env.ENV = 'production'
|
const ENV = process.env.NODE_ENV = process.env.ENV = 'production'
|
||||||
const HOST = process.env.HOST || 'localhost'
|
const HOST = process.env.HOST || 'localhost'
|
||||||
const PORT = process.env.PORT || 8080
|
const PORT = process.env.PORT || 8080
|
||||||
const METADATA = webpackMerge(commonConfig.metadata, {
|
const METADATA = webpackMerge(commonConfig({env: ENV}).metadata, {
|
||||||
host: HOST,
|
host: HOST,
|
||||||
port: PORT,
|
port: PORT,
|
||||||
ENV: ENV,
|
ENV: ENV,
|
||||||
|
@ -166,7 +166,7 @@ module.exports = webpackMerge(commonConfig, {
|
||||||
new NormalModuleReplacementPlugin(
|
new NormalModuleReplacementPlugin(
|
||||||
/angular2-hmr/,
|
/angular2-hmr/,
|
||||||
helpers.root('config/modules/angular2-hmr-prod.js')
|
helpers.root('config/modules/angular2-hmr-prod.js')
|
||||||
),
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin: CompressionPlugin
|
* Plugin: CompressionPlugin
|
||||||
|
@ -175,10 +175,10 @@ module.exports = webpackMerge(commonConfig, {
|
||||||
*
|
*
|
||||||
* See: https://github.com/webpack/compression-webpack-plugin
|
* See: https://github.com/webpack/compression-webpack-plugin
|
||||||
*/
|
*/
|
||||||
new CompressionPlugin({
|
// new CompressionPlugin({
|
||||||
regExp: /\.css$|\.html$|\.js$|\.map$/,
|
// regExp: /\.css$|\.html$|\.js$|\.map$/,
|
||||||
threshold: 2 * 1024
|
// threshold: 2 * 1024
|
||||||
})
|
// })
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
"@angular/platform-browser": "2.0.0-rc.6",
|
"@angular/platform-browser": "2.0.0-rc.6",
|
||||||
"@angular/platform-browser-dynamic": "2.0.0-rc.6",
|
"@angular/platform-browser-dynamic": "2.0.0-rc.6",
|
||||||
"@angular/router": "3.0.0-rc.2",
|
"@angular/router": "3.0.0-rc.2",
|
||||||
"@angularclass/hmr": "^1.0.1",
|
"@angularclass/hmr": "^1.2.0",
|
||||||
"@angularclass/hmr-loader": "^1.0.1",
|
"@angularclass/hmr-loader": "^3.0.1",
|
||||||
"@types/core-js": "^0.9.28",
|
"@types/core-js": "^0.9.28",
|
||||||
"@types/node": "^6.0.38",
|
"@types/node": "^6.0.38",
|
||||||
"@types/source-map": "^0.1.26",
|
"@types/source-map": "^0.1.26",
|
||||||
|
@ -35,6 +35,7 @@
|
||||||
"@types/webpack": "^1.12.29",
|
"@types/webpack": "^1.12.29",
|
||||||
"angular-pipes": "^3.0.0",
|
"angular-pipes": "^3.0.0",
|
||||||
"angular2-template-loader": "^0.5.0",
|
"angular2-template-loader": "^0.5.0",
|
||||||
|
"assets-webpack-plugin": "^3.4.0",
|
||||||
"awesome-typescript-loader": "^2.2.1",
|
"awesome-typescript-loader": "^2.2.1",
|
||||||
"bootstrap-loader": "^1.0.8",
|
"bootstrap-loader": "^1.0.8",
|
||||||
"bootstrap-sass": "^3.3.6",
|
"bootstrap-sass": "^3.3.6",
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
switch (process.env.NODE_ENV) {
|
switch (process.env.NODE_ENV) {
|
||||||
case 'prod':
|
case 'prod':
|
||||||
case 'production':
|
case 'production':
|
||||||
module.exports = require('./config/webpack.prod')
|
module.exports = require('./config/webpack.prod')({env: 'production'})
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'test':
|
case 'test':
|
||||||
case 'testing':
|
case 'testing':
|
||||||
module.exports = require('./config/webpack.test')
|
module.exports = require('./config/webpack.test')({env: 'test'})
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'dev':
|
case 'dev':
|
||||||
case 'development':
|
case 'development':
|
||||||
default:
|
default:
|
||||||
module.exports = require('./config/webpack.dev')
|
module.exports = require('./config/webpack.dev')({env: 'development'})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue