Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

Convert to use new webpack rules syntax vs loaders #1388

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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