fix: use case insensitive regex for webpack loader rules (#4728)

This commit is contained in:
William Chong 2019-01-10 03:48:34 +08:00 committed by Pooya Parsa
parent f85ac94a87
commit 68d8d54e83

View File

@ -50,7 +50,7 @@ export default class WebpackBaseConfig {
normalizeTranspile() { normalizeTranspile() {
// include SFCs in node_modules // include SFCs in node_modules
const items = [/\.vue\.js/] const items = [/\.vue\.js/i]
for (const pattern of this.options.build.transpile) { for (const pattern of this.options.build.transpile) {
if (pattern instanceof RegExp) { if (pattern instanceof RegExp) {
items.push(pattern) items.push(pattern)
@ -188,15 +188,15 @@ export default class WebpackBaseConfig {
return [ return [
{ {
test: /\.vue$/, test: /\.vue$/i,
loader: 'vue-loader', loader: 'vue-loader',
options: this.loaders.vue options: this.loaders.vue
}, },
{ {
test: /\.pug$/, test: /\.pug$/i,
oneOf: [ oneOf: [
{ {
resourceQuery: /^\?vue/, resourceQuery: /^\?vue/i,
use: [{ use: [{
loader: 'pug-plain-loader', loader: 'pug-plain-loader',
options: this.loaders.pugPlain options: this.loaders.pugPlain
@ -214,7 +214,7 @@ export default class WebpackBaseConfig {
] ]
}, },
{ {
test: /\.jsx?$/, test: /\.jsx?$/i,
exclude: (file) => { exclude: (file) => {
// not exclude files outside node_modules // not exclude files outside node_modules
if (!/node_modules/.test(file)) { if (!/node_modules/.test(file)) {
@ -230,12 +230,12 @@ export default class WebpackBaseConfig {
}) })
}, },
{ {
test: /\.ts$/, test: /\.ts$/i,
loader: 'ts-loader', loader: 'ts-loader',
options: this.loaders.ts options: this.loaders.ts
}, },
{ {
test: /\.tsx$/, test: /\.tsx$/i,
use: [ use: [
{ {
loader: require.resolve('babel-loader'), loader: require.resolve('babel-loader'),
@ -248,43 +248,43 @@ export default class WebpackBaseConfig {
] ]
}, },
{ {
test: /\.css$/, test: /\.css$/i,
oneOf: styleLoader.apply('css') oneOf: styleLoader.apply('css')
}, },
{ {
test: /\.p(ost)?css$/, test: /\.p(ost)?css$/i,
oneOf: styleLoader.apply('postcss') oneOf: styleLoader.apply('postcss')
}, },
{ {
test: /\.less$/, test: /\.less$/i,
oneOf: styleLoader.apply('less', { oneOf: styleLoader.apply('less', {
loader: 'less-loader', loader: 'less-loader',
options: this.loaders.less options: this.loaders.less
}) })
}, },
{ {
test: /\.sass$/, test: /\.sass$/i,
oneOf: styleLoader.apply('sass', { oneOf: styleLoader.apply('sass', {
loader: 'sass-loader', loader: 'sass-loader',
options: this.loaders.sass options: this.loaders.sass
}) })
}, },
{ {
test: /\.scss$/, test: /\.scss$/i,
oneOf: styleLoader.apply('scss', { oneOf: styleLoader.apply('scss', {
loader: 'sass-loader', loader: 'sass-loader',
options: this.loaders.scss options: this.loaders.scss
}) })
}, },
{ {
test: /\.styl(us)?$/, test: /\.styl(us)?$/i,
oneOf: styleLoader.apply('stylus', { oneOf: styleLoader.apply('stylus', {
loader: 'stylus-loader', loader: 'stylus-loader',
options: this.loaders.stylus options: this.loaders.stylus
}) })
}, },
{ {
test: /\.(png|jpe?g|gif|svg|webp)$/, test: /\.(png|jpe?g|gif|svg|webp)$/i,
use: perfLoader.asset().concat({ use: perfLoader.asset().concat({
loader: 'url-loader', loader: 'url-loader',
options: Object.assign( options: Object.assign(
@ -294,7 +294,7 @@ export default class WebpackBaseConfig {
}) })
}, },
{ {
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/i,
use: perfLoader.asset().concat({ use: perfLoader.asset().concat({
loader: 'url-loader', loader: 'url-loader',
options: Object.assign( options: Object.assign(
@ -304,7 +304,7 @@ export default class WebpackBaseConfig {
}) })
}, },
{ {
test: /\.(webm|mp4|ogv)$/, test: /\.(webm|mp4|ogv)$/i,
use: perfLoader.asset().concat({ use: perfLoader.asset().concat({
loader: 'file-loader', loader: 'file-loader',
options: Object.assign( options: Object.assign(