1 Star 0 Fork 27

Asxing/website

forked from dromara/website 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
gulpfile.js 1.82 KB
一键复制 编辑 原始数据 按行查看 历史
xiaoyu 提交于 2018-10-19 18:49 . first commit
require('babel-register')();
const gulp = require('gulp');
const gutil = require('gulp-util');
const webpack = require('webpack');
const opn = require('opn');
const WebpackDevServer = require('webpack-dev-server');
const siteConfig = require('./site_config/site').default;
const webpackConfig = require('./webpack.config.js');
const port = siteConfig.port || 8080;
// The development server (the recommended option for development)
gulp.task('default', ['webpack-dev-server']);
// Production build
gulp.task('build', ['webpack:build']);
gulp.task('webpack-dev-server', () => {
// modify some webpack config options
const myConfig = Object.create(webpackConfig);
myConfig.plugins.push(new webpack.SourceMapDevToolPlugin({}));
// Start a webpack-dev-server
new WebpackDevServer(webpack(myConfig), {
publicPath: `http://127.0.0.1:${port}/build/`,
stats: {
colors: true,
},
}).listen(port, '127.0.0.1', err => {
if (err) throw new gutil.PluginError('webpack-dev-server', err);
opn(`http://127.0.0.1:${port}/`);
gutil.log('[webpack-dev-server]', `http://127.0.0.1:${port}/webpack-dev-server/index.html`);
});
});
gulp.task('webpack:build', callback => {
// modify some webpack config options
const myConfig = Object.create(webpackConfig);
myConfig.output.publicPath = `${siteConfig.rootPath}/build/`;
myConfig.plugins = myConfig.plugins.concat(
new webpack.DefinePlugin({
'process.env': {
// This has effect on the react lib size
NODE_ENV: JSON.stringify('production'),
},
}),
new webpack.optimize.UglifyJsPlugin()
);
// run webpack
webpack(myConfig, (err, stats) => {
if (err) throw new gutil.PluginError('webpack:build', err);
gutil.log(
'[webpack:build]',
stats.toString({
colors: true,
})
);
callback();
});
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/asxing/website.git
git@gitee.com:asxing/website.git
asxing
website
website
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385