2016-11-10 02:38:11 +00:00
|
|
|
'use strict'
|
|
|
|
|
2016-11-07 01:34:58 +00:00
|
|
|
const vueLoaderConfig = require('./vue-loader.config')
|
2016-11-18 09:38:47 +00:00
|
|
|
const { defaults } = require('lodash')
|
2016-11-09 22:59:41 +00:00
|
|
|
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
|
|
|
|
|
|
2016-11-18 03:02:43 +00:00
|
|
|
| This is the config which is extended by the server and client
|
2016-11-07 01:34:58 +00:00
|
|
|
| webpack config files
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
*/
|
2016-11-09 22:59:41 +00:00
|
|
|
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/')
|
2016-11-09 22:59:41 +00:00
|
|
|
},
|
|
|
|
resolve: {
|
2016-11-16 16:55:15 +00:00
|
|
|
// Disable for now
|
2016-11-14 22:59:54 +00:00
|
|
|
alias: {
|
2016-12-08 06:45:40 +00:00
|
|
|
'~': join(this.srcDir),
|
|
|
|
'static': join(this.srcDir, 'static'), // use in template with <img src="~static/nuxt.png" />
|
|
|
|
'~static': join(this.srcDir, 'static'),
|
|
|
|
'assets': join(this.srcDir, 'assets'), // use in template with <img src="~static/nuxt.png" />
|
|
|
|
'~assets': join(this.srcDir, 'assets'),
|
|
|
|
'~plugins': join(this.srcDir, 'plugins'),
|
|
|
|
'~store': join(this.srcDir, 'store'),
|
2016-11-24 00:40:04 +00:00
|
|
|
'~router': join(this.dir, '.nuxt/router'),
|
2016-12-08 06:45:40 +00:00
|
|
|
'~pages': join(this.srcDir, 'pages'),
|
|
|
|
'~components': join(this.srcDir, 'components')
|
2016-11-14 22:59:54 +00:00
|
|
|
},
|
2016-11-09 22:59:41 +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',
|
2016-11-18 09:38:47 +00:00
|
|
|
query: vueLoaderConfig.call(this)
|
2016-11-09 22:59:41 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
2016-11-14 22:59:54 +00:00
|
|
|
loader: 'babel-loader',
|
2016-11-09 22:59:41 +00:00
|
|
|
exclude: /node_modules/,
|
2016-11-18 09:38:47 +00:00
|
|
|
query: defaults(this.options.build.babel, {
|
|
|
|
presets: [
|
|
|
|
['es2015', { modules: false }],
|
|
|
|
'stage-2'
|
|
|
|
],
|
|
|
|
cacheDirectory: !!this.dev
|
|
|
|
})
|
2016-11-07 01:34:58 +00:00
|
|
|
}
|
2016-11-09 22:59:41 +00:00
|
|
|
]
|
2016-11-17 21:12:21 +00:00
|
|
|
},
|
|
|
|
plugins: this.options.build.plugins
|
2016-11-07 01:34:58 +00:00
|
|
|
}
|
2016-11-09 22:59:41 +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
|
|
|
}
|