mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
generate dist lib
This commit is contained in:
parent
59408bd329
commit
09e637cf4b
@ -1,2 +0,0 @@
|
||||
# Excludes examples
|
||||
examples
|
@ -246,7 +246,7 @@ Promise.all(resolveComponents)
|
||||
// Hot reloading
|
||||
if (module.hot) hotReloadAPI(_app)
|
||||
// Call window.onNuxtReady callbacks
|
||||
nuxtReady(_app)
|
||||
Vue.nextTick(() => nuxtReady(_app))
|
||||
}
|
||||
<% if (store) { %>
|
||||
// Replace store state
|
||||
|
@ -10,6 +10,8 @@ const pify = require('pify')
|
||||
const webpack = require('webpack')
|
||||
const { createBundleRenderer } = require('vue-server-renderer')
|
||||
const { join, resolve, sep, posix } = require('path')
|
||||
const clientWebpackConfig = require('./webpack/client.config.js')
|
||||
const serverWebpackConfig = require('./webpack/server.config.js')
|
||||
const basename = posix.basename
|
||||
const remove = pify(fs.remove)
|
||||
const readFile = pify(fs.readFile)
|
||||
@ -182,8 +184,8 @@ function * generateRoutesAndFiles () {
|
||||
loading: (typeof this.options.loading === 'string' ? r(this.srcDir, this.options.loading) : this.options.loading),
|
||||
transition: this.options.transition,
|
||||
components: {
|
||||
Loading: r(__dirname, '..', 'app', 'components', 'nuxt-loading.vue'),
|
||||
ErrorPage: r(__dirname, '..', 'app', 'components', 'nuxt-error.vue')
|
||||
Loading: r(__dirname, 'app', 'components', 'nuxt-loading.vue'),
|
||||
ErrorPage: r(__dirname, 'app', 'components', 'nuxt-error.vue')
|
||||
}
|
||||
}
|
||||
if (templateVars.loading === 'string' && templateVars.loading.slice(-4) !== '.vue') {
|
||||
@ -211,7 +213,7 @@ function * generateRoutesAndFiles () {
|
||||
templateVars.components.ErrorPage = r(this.srcDir, 'layouts/error.vue')
|
||||
}
|
||||
let moveTemplates = templatesFiles.map((file) => {
|
||||
return readFile(r(__dirname, '..', 'app', file), 'utf8')
|
||||
return readFile(r(__dirname, 'app', file), 'utf8')
|
||||
.then((fileContent) => {
|
||||
const template = _.template(fileContent)
|
||||
const content = template(templateVars)
|
||||
@ -222,13 +224,11 @@ function * generateRoutesAndFiles () {
|
||||
}
|
||||
|
||||
function getWebpackClientConfig () {
|
||||
const clientConfigPath = r(__dirname, 'webpack', 'client.config.js')
|
||||
return require(clientConfigPath).call(this)
|
||||
return clientWebpackConfig.call(this)
|
||||
}
|
||||
|
||||
function getWebpackServerConfig () {
|
||||
const configServerPath = r(__dirname, 'webpack', 'server.config.js')
|
||||
return require(configServerPath).call(this)
|
||||
return serverWebpackConfig.call(this)
|
||||
}
|
||||
|
||||
function createWebpackMiddlewares () {
|
||||
|
@ -14,7 +14,7 @@ const { urlJoin } = require('../../utils')
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
module.exports = function () {
|
||||
const nodeModulesDir = join(__dirname, '..', '..', '..', 'node_modules')
|
||||
const nodeModulesDir = join(__dirname, '..', 'node_modules')
|
||||
let config = {
|
||||
devtool: 'source-map',
|
||||
entry: {
|
||||
|
@ -3,7 +3,7 @@
|
||||
const _ = require('lodash')
|
||||
const webpack = require('webpack')
|
||||
const ExtractTextPlugin = require('extract-text-webpack-plugin')
|
||||
const base = require('./base.config')
|
||||
const base = require('./base.config.js')
|
||||
const { resolve } = require('path')
|
||||
|
||||
/*
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
const _ = require('lodash')
|
||||
const webpack = require('webpack')
|
||||
const base = require('./base.config')
|
||||
const base = require('./base.config.js')
|
||||
const { uniq } = require('lodash')
|
||||
const { existsSync } = require('fs')
|
||||
const { existsSync, readFileSync } = require('fs')
|
||||
const { resolve } = require('path')
|
||||
|
||||
/*
|
||||
@ -40,11 +40,14 @@ module.exports = function () {
|
||||
})
|
||||
|
||||
// Externals
|
||||
const nuxtPackageJson = require(resolve(__dirname, '..', '..', '..', 'package.json'))
|
||||
const projectPackageJson = resolve(this.dir, 'package.json')
|
||||
const nuxtPackageJson = require('../../../package.json')
|
||||
const projectPackageJsonPath = resolve(this.dir, 'package.json')
|
||||
config.externals = Object.keys(nuxtPackageJson.dependencies || {})
|
||||
if (existsSync(projectPackageJson)) {
|
||||
config.externals = config.externals.concat(Object.keys(require(projectPackageJson).dependencies || {}))
|
||||
if (existsSync(projectPackageJsonPath)) {
|
||||
try {
|
||||
const projectPackageJson = JSON.parse(readFileSync(projectPackageJsonPath))
|
||||
config.externals = config.externals.concat(Object.keys(projectPackageJson.dependencies || {}))
|
||||
} catch (e) {}
|
||||
}
|
||||
config.externals = uniq(config.externals)
|
||||
|
||||
|
25
package.json
25
package.json
@ -10,12 +10,16 @@
|
||||
"name": "Alexandre Chopin"
|
||||
}
|
||||
],
|
||||
"main": "index.js",
|
||||
"main": "./dist/nuxt.js",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/nuxt/nuxt.js"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"dist"
|
||||
],
|
||||
"keywords": [
|
||||
"nuxt",
|
||||
"nuxt.js",
|
||||
@ -31,15 +35,20 @@
|
||||
"nuxt": "./bin/nuxt"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "npm run lint",
|
||||
"lint": "eslint --ext .js,.vue bin lib pages test index.js --ignore-pattern lib/app",
|
||||
"precommit": "npm run lint"
|
||||
"test": "nyc ava test/",
|
||||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
|
||||
"lint": "eslint --ext .js,.vue bin lib pages test --ignore-pattern lib/app",
|
||||
"build": "webpack",
|
||||
"watch": "webpack --watch",
|
||||
"precommit": "npm run lint",
|
||||
"prepublish": "npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-html": "^0.0.6",
|
||||
"autoprefixer": "^6.5.3",
|
||||
"babel-core": "^6.18.2",
|
||||
"babel-loader": "^6.2.8",
|
||||
"babel-polyfill": "^6.20.0",
|
||||
"babel-preset-es2015": "^6.18.0",
|
||||
"babel-preset-stage-2": "^6.18.0",
|
||||
"chokidar": "^1.6.1",
|
||||
@ -73,12 +82,18 @@
|
||||
"webpack-hot-middleware": "^2.13.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^0.17.0",
|
||||
"babel-eslint": "^7.1.1",
|
||||
"codecov": "^1.0.1",
|
||||
"copy-webpack-plugin": "^4.0.1",
|
||||
"eslint": "^3.10.2",
|
||||
"eslint-config-standard": "^6.2.1",
|
||||
"eslint-plugin-html": "^1.7.0",
|
||||
"eslint-plugin-promise": "^3.4.0",
|
||||
"eslint-plugin-standard": "^2.0.1",
|
||||
"nodemon": "^1.11.0"
|
||||
"jsdom": "^9.8.3",
|
||||
"json-loader": "^0.5.4",
|
||||
"nyc": "^10.0.0",
|
||||
"webpack-node-externals": "^1.5.4"
|
||||
}
|
||||
}
|
||||
|
50
webpack.config.js
Normal file
50
webpack.config.js
Normal file
@ -0,0 +1,50 @@
|
||||
var nodeExternals = require('webpack-node-externals')
|
||||
var CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||
var resolve = require('path').resolve
|
||||
var r = function (p) { return resolve(__dirname, p) }
|
||||
|
||||
module.exports = {
|
||||
target: 'node',
|
||||
node: {
|
||||
__dirname: false,
|
||||
__filename: false
|
||||
},
|
||||
devtool: 'source-map',
|
||||
entry: ['babel-polyfill', r('./lib/nuxt.js')],
|
||||
output: {
|
||||
path: r('./dist'),
|
||||
filename: 'nuxt.js',
|
||||
libraryTarget: 'commonjs2'
|
||||
},
|
||||
externals: [
|
||||
nodeExternals({
|
||||
whitelist: ['babel-polyfill']
|
||||
})
|
||||
],
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.json$/,
|
||||
loader: 'json-loader'
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
loader: 'babel-loader',
|
||||
exclude: /node_modules/,
|
||||
query: {
|
||||
presets: [
|
||||
['es2015', { modules: false }],
|
||||
'stage-2'
|
||||
],
|
||||
cacheDirectory: true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new CopyWebpackPlugin([
|
||||
{ from: 'lib/app', to: 'app' },
|
||||
{ from: 'lib/views', to: 'views' }
|
||||
])
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user