我在mac 上运行 docsite start 时一直报错:
AssertionError [ERR_ASSERTION]: Task function must be specified at Gulp.set [as _setTask]
package.json
{ "name": "site", "version": "0.0.1", "private": true, "scripts": { "start": "docsite start", "build": "docsite build" }, "devDependencies": { "babel-core": "6.23.1", "babel-eslint": "^6.0.5", "babel-loader": "6.4.0", "babel-plugin-transform-class-properties": "^6.24.1", "babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-transform-object-assign": "^6.22.0", "babel-plugin-transform-object-rest-spread": "^6.23.0", "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-es2015": "6.22.0", "babel-preset-react": "6.23.0", "babel-preset-stage-0": "6.22.0", "babel-register": "^6.26.0", "css-loader": "0.6.12", "docsite": "^1.1.0", "eslint": "^3.6.0", "eslint-config-ali": "^1.0.0", "eslint-plugin-import": "*", "eslint-plugin-react": "*", "extract-text-webpack-plugin": "^2.1.2", "gulp": "^4.0.2", "gulp-util": "2.2.20", "json-loader": "*", "node-libs-browser": "2.0.0", "node-sass": "^4.7.2", "opn": "^5.3.0", "raw-loader": "^0.5.1", "react": "^16.5.2", "react-dom": "^16.5.2", "sass-loader": "6.0.2", "style-loader": "0.6.5", "webpack": "^2.6.1", "webpack-dev-server": "^2.4.5" }, "dependencies": { "classnames": "^2.2.5", "core-decorators": "^0.20.0", "js-cookie": "^2.2.0", "react-scroll": "^1.7.9", "react-tilt": "^0.1.4", "whatwg-fetch": "^2.0.4" } }
.babelrc
webpack.config.js
`
const path = require('path');
const fs = require('fs');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const entry = {};
const targetPath = path.join(__dirname, './src/pages');
fs.readdirSync(targetPath).forEach(page => {
if (
fs.statSync(path.join(targetPath, page)).isDirectory() &&
fs.existsSync(path.join(targetPath, page, 'index.jsx'))
) {
entry[page] = path.join(targetPath, page, 'index.jsx');
}
});
module.exports = {
entry,
output: {
path: path.join(__dirname, 'build'),
filename: '[name].js',
},
externals: {
react: 'React',
'react-dom': 'ReactDOM',
},
module: {
loaders: [
{
test: /.js|jsx$/,
exclude: [/node_modules/, /build/lib/, /.min.js$/],
use: 'babel-loader',
},
{
test: /.(s)?css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'sass-loader'],
}),
},
{
test: /.json?$/,
exclude: /node_modules/,
use: 'json-loader',
},
],
},
resolve: {
extensions: ['.js', '.jsx', '.json'],
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new ExtractTextPlugin('[name].css'),
],
};
`