Skip to content

Commit

Permalink
Convert to use new webpack rules syntax vs loaders
Browse files Browse the repository at this point in the history
  • Loading branch information
adamduren committed Feb 11, 2018
1 parent 09bd434 commit 5590395
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ var ionicWebpackFactory = require(process.env.IONIC_WEBPACK_FACTORY);
var ModuleConcatPlugin = require('webpack/lib/optimize/ModuleConcatenationPlugin');
var PurifyPlugin = require('@angular-devkit/build-optimizer').PurifyPlugin;

var optimizedProdLoaders = [
var optimizedProdRules = [
{
test: /\.json$/,
loader: 'json-loader'
use: [
'json-loader',
]
},
{
test: /\.js$/,
loader: [
use: [
{
loader: process.env.IONIC_CACHE_LOADER
},
Expand All @@ -36,7 +38,7 @@ var optimizedProdLoaders = [
},
{
test: /\.ts$/,
loader: [
use: [
{
loader: process.env.IONIC_CACHE_LOADER
},
Expand All @@ -55,11 +57,11 @@ var optimizedProdLoaders = [
}
];

function getProdLoaders() {
function getProdRules() {
if (process.env.IONIC_OPTIMIZE_JS === 'true') {
return optimizedProdLoaders;
return optimizedProdRules;
}
return devConfig.module.loaders;
return devConfig.module.rules;
}

var devConfig = {
Expand All @@ -78,16 +80,20 @@ var devConfig = {
},

module: {
loaders: [
rules: [
{
test: /\.json$/,
loader: 'json-loader'
use: [
'json-loader',
]
},
{
test: /\.ts$/,
loader: process.env.IONIC_WEBPACK_LOADER
use: [
process.env.IONIC_WEBPACK_LOADER,
]
}
]
],
},

plugins: [
Expand Down Expand Up @@ -120,7 +126,7 @@ var prodConfig = {
},

module: {
loaders: getProdLoaders()
rules: getProdRules()
},

plugins: [
Expand Down

0 comments on commit 5590395

Please sign in to comment.