2016-11-10 02:38:11 +00:00
|
|
|
'use strict'
|
|
|
|
|
2017-01-11 19:14:59 +00:00
|
|
|
import vueLoaderConfig from './vue-loader.config'
|
|
|
|
import { defaults } from 'lodash'
|
|
|
|
import { join } from 'path'
|
2017-03-16 17:52:38 +00:00
|
|
|
import { isUrl, urlJoin } from '../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
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
*/
|
2017-01-11 19:14:59 +00:00
|
|
|
export default function ({ isClient, isServer }) {
|
2016-12-09 17:54:17 +00:00
|
|
|
const nodeModulesDir = join(__dirname, '..', 'node_modules')
|
2016-11-09 22:59:41 +00:00
|
|
|
let config = {
|
2017-04-14 14:31:31 +00:00
|
|
|
devtool: (this.dev ? 'cheap-module-source-map' : false),
|
2016-11-09 22:59:41 +00:00
|
|
|
entry: {
|
2017-01-11 21:18:47 +00:00
|
|
|
vendor: ['vue', 'vue-router', 'vue-meta']
|
2016-11-09 22:59:41 +00:00
|
|
|
},
|
|
|
|
output: {
|
2017-03-16 17:52:38 +00:00
|
|
|
publicPath: (isUrl(this.options.build.publicPath) ? this.options.build.publicPath : urlJoin(this.options.router.base, this.options.build.publicPath))
|
2016-11-09 22:59:41 +00:00
|
|
|
},
|
2016-12-15 17:53:00 +00:00
|
|
|
performance: {
|
2017-03-24 15:12:59 +00:00
|
|
|
maxEntrypointSize: 300000,
|
|
|
|
maxAssetSize: 300000,
|
2016-12-15 17:53:00 +00:00
|
|
|
hints: (this.dev ? false : 'warning')
|
|
|
|
},
|
2016-11-09 22:59:41 +00:00
|
|
|
resolve: {
|
2016-12-12 15:30:17 +00:00
|
|
|
extensions: ['.js', '.json', '.vue'],
|
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'),
|
2017-04-25 11:03:26 +00:00
|
|
|
'assets': join(this.srcDir, 'assets'), // use in template with <img src="~assets/nuxt.png" />
|
2016-12-08 06:45:40 +00:00
|
|
|
'~assets': join(this.srcDir, 'assets'),
|
|
|
|
'~plugins': join(this.srcDir, 'plugins'),
|
2017-01-31 23:22:02 +00:00
|
|
|
'~store': join(this.dir, '.nuxt/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',
|
2017-01-09 14:10:22 +00:00
|
|
|
query: vueLoaderConfig.call(this, { isClient, isServer })
|
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, {
|
2017-02-17 15:13:51 +00:00
|
|
|
presets: ['vue-app'],
|
2017-04-17 13:27:32 +00:00
|
|
|
babelrc: false,
|
2016-11-18 09:38:47 +00:00
|
|
|
cacheDirectory: !!this.dev
|
|
|
|
})
|
2017-03-24 00:28:04 +00:00
|
|
|
},
|
2017-03-25 02:38:19 +00:00
|
|
|
{ test: /\.css$/, loader: 'vue-style-loader!css-loader' },
|
|
|
|
{ test: /\.less$/, loader: 'vue-style-loader!css-loader!less-loader' },
|
|
|
|
{ test: /\.sass$/, loader: 'vue-style-loader!css-loader!sass-loader?indentedSyntax' },
|
|
|
|
{ test: /\.scss$/, loader: 'vue-style-loader!css-loader!sass-loader' },
|
|
|
|
{ test: /\.styl(us)?$/, loader: 'vue-style-loader!css-loader!stylus-loader' }
|
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
|
|
|
}
|