mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-15 19:16:18 +02:00
setup build process for monaco files. public path is set to relative to support async chunk loading in app and extension both
This commit is contained in:
25
gulpfile.js
25
gulpfile.js
@ -22,8 +22,8 @@ function minifyJs(fileName) {
|
|||||||
).code;
|
).code;
|
||||||
fs.writeFileSync(fileName, minifiedContent);
|
fs.writeFileSync(fileName, minifiedContent);
|
||||||
console.log(
|
console.log(
|
||||||
`[${fileName}]: ${content.length / 1024}M -> ${minifiedContent.length /
|
`[${fileName}]: ${content.length / 1024}K -> ${minifiedContent.length /
|
||||||
1024}M`
|
1024}K`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
gulp.task('runWebpack', function() {
|
gulp.task('runWebpack', function() {
|
||||||
@ -41,6 +41,9 @@ gulp.task('copyFiles', function() {
|
|||||||
gulp.src('src/lib/transpilers/*').pipe(gulp.dest('app/lib/transpilers')),
|
gulp.src('src/lib/transpilers/*').pipe(gulp.dest('app/lib/transpilers')),
|
||||||
gulp.src('src/lib/prettier-worker.js').pipe(gulp.dest('app/lib/')),
|
gulp.src('src/lib/prettier-worker.js').pipe(gulp.dest('app/lib/')),
|
||||||
gulp.src('src/lib/prettier/*').pipe(gulp.dest('app/lib/prettier')),
|
gulp.src('src/lib/prettier/*').pipe(gulp.dest('app/lib/prettier')),
|
||||||
|
gulp
|
||||||
|
.src(['!src/lib/monaco/monaco.bundle.js', 'src/lib/monaco/**/*'])
|
||||||
|
.pipe(gulp.dest('app/lib/monaco')),
|
||||||
gulp.src('src/lib/screenlog.js').pipe(gulp.dest('app/lib')),
|
gulp.src('src/lib/screenlog.js').pipe(gulp.dest('app/lib')),
|
||||||
gulp.src('icons/*').pipe(gulp.dest('app/icons')),
|
gulp.src('icons/*').pipe(gulp.dest('app/icons')),
|
||||||
gulp.src('src/assets/*').pipe(gulp.dest('app/assets')),
|
gulp.src('src/assets/*').pipe(gulp.dest('app/assets')),
|
||||||
@ -63,6 +66,7 @@ gulp.task('copyFiles', function() {
|
|||||||
.src('build/vendor.*.js')
|
.src('build/vendor.*.js')
|
||||||
.pipe(rename('vendor.js'))
|
.pipe(rename('vendor.js'))
|
||||||
.pipe(gulp.dest('app')),
|
.pipe(gulp.dest('app')),
|
||||||
|
gulp.src('build/monaco.*.js').pipe(gulp.dest('app')),
|
||||||
|
|
||||||
// Following CSS are copied to build/ folder where they'll be referenced by
|
// Following CSS are copied to build/ folder where they'll be referenced by
|
||||||
// useRef plugin to concat into one.
|
// useRef plugin to concat into one.
|
||||||
@ -120,8 +124,11 @@ gulp.task('minify', function() {
|
|||||||
debug: true
|
debug: true
|
||||||
},
|
},
|
||||||
details => {
|
details => {
|
||||||
console.log(`${details.name}: ${details.stats.originalSize}`);
|
console.log(
|
||||||
console.log(`${details.name}: ${details.stats.minifiedSize}`);
|
`${details.name}: ${details.stats.originalSize} 👉🏼 ${
|
||||||
|
details.stats.minifiedSize
|
||||||
|
}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -138,7 +145,7 @@ gulp.task('fixIndex', function() {
|
|||||||
|
|
||||||
// vendor.hash.js gets created outside our markers, so remove it
|
// vendor.hash.js gets created outside our markers, so remove it
|
||||||
contents = contents.replace(
|
contents = contents.replace(
|
||||||
/\<script src="\/vendor\.[\S\s]*?\<\/script\>/,
|
/\<script src="[\S\s]*?vendor\.[\S\s]*?\<\/script\>/,
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -171,18 +178,12 @@ gulp.task('packageExtension', function() {
|
|||||||
child_process.execSync('cp src/options.html extension');
|
child_process.execSync('cp src/options.html extension');
|
||||||
child_process.execSync('cp src/eventPage.js extension');
|
child_process.execSync('cp src/eventPage.js extension');
|
||||||
child_process.execSync('cp src/icon-16.png extension');
|
child_process.execSync('cp src/icon-16.png extension');
|
||||||
child_process.execSync(
|
child_process.execSync('rm -rf extension/service-worker.js');
|
||||||
'rm -rf extension/service-worker.js extension/partials'
|
|
||||||
);
|
|
||||||
return merge(
|
return merge(
|
||||||
gulp
|
gulp
|
||||||
.src('build/bundle.*.js')
|
.src('build/bundle.*.js')
|
||||||
.pipe(rename('script.js'))
|
.pipe(rename('script.js'))
|
||||||
.pipe(gulp.dest('extension')),
|
.pipe(gulp.dest('extension')),
|
||||||
gulp
|
|
||||||
.src('build/vendor.*.js')
|
|
||||||
.pipe(rename('vendor.js'))
|
|
||||||
.pipe(gulp.dest('extension')),
|
|
||||||
|
|
||||||
gulp
|
gulp
|
||||||
.src('extension/**/*')
|
.src('extension/**/*')
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import CopyWebpackPlugin from 'copy-webpack-plugin';
|
|
||||||
var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
|
var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,7 +27,8 @@ export default function(config, env, helpers) {
|
|||||||
|
|
||||||
if (env.isProd) {
|
if (env.isProd) {
|
||||||
config.devtool = false; // disable sourcemaps
|
config.devtool = false; // disable sourcemaps
|
||||||
|
config.output.publicPath = './';
|
||||||
|
config.output.chunkFilename = '[name].chunk.js';
|
||||||
config.plugins.push(
|
config.plugins.push(
|
||||||
new CommonsChunkPlugin({
|
new CommonsChunkPlugin({
|
||||||
name: 'vendor',
|
name: 'vendor',
|
||||||
|
Reference in New Issue
Block a user