Remove build.loaders option

This commit is contained in:
Sébastien Chopin 2017-06-11 21:04:59 +02:00
parent 2926b08344
commit 2913d90109
2 changed files with 18 additions and 23 deletions

View File

@ -35,31 +35,13 @@ const defaults = {
app: 'nuxt.bundle.[chunkhash].js' app: 'nuxt.bundle.[chunkhash].js'
}, },
vendor: [], vendor: [],
loaders: [],
plugins: [], plugins: [],
babel: {}, babel: {},
postcss: [], postcss: [],
templates: [], templates: [],
watch: [] watch: []
} }
const defaultsLoaders = [
{
test: /\.(png|jpe?g|gif|svg)$/,
loader: 'url-loader',
query: {
limit: 1000, // 1KO
name: 'img/[name].[hash:7].[ext]'
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
query: {
limit: 1000, // 1 KO
name: 'fonts/[name].[hash:7].[ext]'
}
}
]
const defaultsPostcss = [ const defaultsPostcss = [
require('autoprefixer')({ require('autoprefixer')({
browsers: ['last 3 versions'] browsers: ['last 3 versions']
@ -69,7 +51,6 @@ const defaultsPostcss = [
export function options () { export function options () {
// Defaults build options // Defaults build options
let extraDefaults = {} let extraDefaults = {}
if (this.options.build && !Array.isArray(this.options.build.loaders)) extraDefaults.loaders = defaultsLoaders
if (this.options.build && !Array.isArray(this.options.build.postcss)) extraDefaults.postcss = defaultsPostcss if (this.options.build && !Array.isArray(this.options.build.postcss)) extraDefaults.postcss = defaultsPostcss
this.options.build = _.defaultsDeep(this.options.build, defaults, extraDefaults) this.options.build = _.defaultsDeep(this.options.build, defaults, extraDefaults)
/* istanbul ignore if */ /* istanbul ignore if */

View File

@ -77,7 +77,23 @@ export default function ({ isClient, isServer }) {
{ test: /\.less$/, use: styleLoader.call(this, 'less', 'less-loader') }, { test: /\.less$/, use: styleLoader.call(this, 'less', 'less-loader') },
{ test: /\.sass$/, use: styleLoader.call(this, 'sass', 'sass-loader?indentedSyntax&sourceMap') }, { test: /\.sass$/, use: styleLoader.call(this, 'sass', 'sass-loader?indentedSyntax&sourceMap') },
{ test: /\.scss$/, use: styleLoader.call(this, 'sass', 'sass-loader?sourceMap') }, { test: /\.scss$/, use: styleLoader.call(this, 'sass', 'sass-loader?sourceMap') },
{ test: /\.styl(us)?$/, use: styleLoader.call(this, 'stylus', 'stylus-loader') } { test: /\.styl(us)?$/, use: styleLoader.call(this, 'stylus', 'stylus-loader') },
{
test: /\.(png|jpe?g|gif|svg)$/,
loader: 'url-loader',
query: {
limit: 1000, // 1KO
name: 'img/[name].[hash:7].[ext]'
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
query: {
limit: 1000, // 1 KO
name: 'fonts/[name].[hash:7].[ext]'
}
}
] ]
}, },
plugins: this.options.build.plugins plugins: this.options.build.plugins
@ -88,8 +104,6 @@ export default function ({ isClient, isServer }) {
new ExtractTextPlugin({filename: this.options.build.filenames.css}) new ExtractTextPlugin({filename: this.options.build.filenames.css})
) )
} }
// Add nuxt build loaders (can be configured in nuxt.config.js)
config.module.rules = config.module.rules.concat(this.options.build.loaders)
// Return config // Return config
return config return config
} }