Nuxt/lib/build/webpack/base.config.js

71 lines
2.0 KiB
JavaScript
Raw Normal View History

'use strict'
2016-11-07 01:34:58 +00:00
const vueLoaderConfig = require('./vue-loader.config')
const { join } = require('path')
2016-11-10 18:34:59 +00:00
const { urlJoin } = require('../../utils')
2016-11-07 01:34:58 +00:00
/*
|--------------------------------------------------------------------------
| Webpack Shared Config
|
| This is the config which is extented by the server and client
| webpack config files
|--------------------------------------------------------------------------
*/
module.exports = function () {
const nodeModulesDir = join(__dirname, '..', '..', '..', 'node_modules')
let config = {
devtool: 'source-map',
entry: {
vendor: ['vue', 'vue-router', 'vue-meta', 'es6-promise', 'es6-object-assign']
},
output: {
2016-11-10 18:34:59 +00:00
publicPath: urlJoin(this.options.router.base, '/_nuxt/')
},
resolve: {
2016-11-16 16:55:15 +00:00
// Disable for now
2016-11-14 22:59:54 +00:00
alias: {
2016-11-16 16:55:15 +00:00
'static': join(this.dir, 'static'), // use in template with <img src="~static/nuxt.png" />
'~static': join(this.dir, 'static'),
'assets': join(this.dir, 'assets'), // use in template with <img src="~static/nuxt.png" />
'~assets': join(this.dir, 'assets'),
'~plugins': join(this.dir, 'plugins'),
'~store': join(this.dir, 'store'),
'~pages': join(this.dir, 'pages'),
'~components': join(this.dir, 'components')
2016-11-14 22:59:54 +00:00
},
modules: [
nodeModulesDir,
join(this.dir, 'node_modules')
]
},
resolveLoader: {
modules: [
nodeModulesDir,
join(this.dir, 'node_modules')
]
},
module: {
rules: [
{
test: /\.vue$/,
2016-11-14 22:59:54 +00:00
loader: 'vue-loader',
options: vueLoaderConfig.call(this)
},
{
test: /\.js$/,
2016-11-14 22:59:54 +00:00
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: ['es2015', 'stage-2']
}
2016-11-07 01:34:58 +00:00
}
]
}
2016-11-07 01:34:58 +00:00
}
// 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
2016-11-07 01:34:58 +00:00
}