diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 index 7471ca92f..9d37dfe99 --- a/Makefile +++ b/Makefile @@ -97,6 +97,10 @@ TAGS ?= TAGS_SPLIT := $(subst $(COMMA), ,$(TAGS)) TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags +ifeq ($(filter $(TAGS_SPLIT),bindata),bindata) + WEBPACK_CONFIGS = webpack_pro.config.js +endif + GO_DIRS := cmd integrations models modules routers build services vendor GO_SOURCES := $(wildcard *.go) GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" -not -path modules/options/bindata.go -not -path modules/public/bindata.go -not -path modules/templates/bindata.go) @@ -290,7 +294,10 @@ lint-backend: golangci-lint revive vet swagger-check swagger-validate test-vendo .PHONY: lint-frontend lint-frontend: node_modules - npx eslint web_src/js webpack.config.js + npx eslint web_src/js webpack_pro.config.js + @echo "1"; + @echo $(WEBPACK_CONFIGS) + #npx eslint web_src/js $(WEBPACK_CONFIGS) npx stylelint web_src/less .PHONY: watch-frontend @@ -514,6 +521,8 @@ generate: $(TAGS_PREREQ) CC= GOOS= GOARCH= $(GO) generate -mod=vendor -tags '$(TAGS)' $(GO_PACKAGES) $(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ) + @echo "2" + @echo $(WEBPACK_CONFIGS) $(GO) build -mod=vendor $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@ .PHONY: release diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index c60740b87..ae21e89c7 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -435,6 +435,9 @@ func NotebookDel(ctx *context.Context) { return } + + + _, err := modelarts.DelNotebook2(jobID) if err != nil { log.Error("DelNotebook2(%s) failed:%v", task.JobName, err.Error()) diff --git a/web_src/js/components/MinioUploader.vue b/web_src/js/components/MinioUploader.vue index 0699f957e..87a70097f 100755 --- a/web_src/js/components/MinioUploader.vue +++ b/web_src/js/components/MinioUploader.vue @@ -101,6 +101,7 @@ export default { this.dropzoneUploader = dropzoneUploader; }, + methods: { resetStatus() { this.progress = 0; diff --git a/webpack_pro.config.js b/webpack_pro.config.js new file mode 100755 index 000000000..c5d204b02 --- /dev/null +++ b/webpack_pro.config.js @@ -0,0 +1,274 @@ +const cssnano = require('cssnano'); +const fastGlob = require('fast-glob'); +const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries'); +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin'); +const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); +const PostCSSPresetEnv = require('postcss-preset-env'); +const PostCSSSafeParser = require('postcss-safe-parser'); +const SpriteLoaderPlugin = require('svg-sprite-loader/plugin'); +const TerserPlugin = require('terser-webpack-plugin'); +const VueLoaderPlugin = require('vue-loader/lib/plugin'); +const {statSync} = require('fs'); +const {resolve, parse} = require('path'); +//const {SourceMapDevToolPlugin} = require('webpack'); + +const glob = (pattern) => fastGlob.sync(pattern, {cwd: __dirname, absolute: true}); + +const themes = {}; +for (const path of glob('web_src/less/themes/*.less')) { + themes[parse(path).name] = [path]; +} + +const isProduction = process.env.NODE_ENV !== 'development'; + +module.exports = { + mode: isProduction ? 'production' : 'development', + entry: { + index: [ + resolve(__dirname, 'web_src/js/index.js'), + resolve(__dirname, 'web_src/less/index.less'), + ], + swagger: [ + resolve(__dirname, 'web_src/js/standalone/swagger.js'), + ], + jquery: [ + resolve(__dirname, 'web_src/js/jquery.js'), + ], + icons: glob('node_modules/@primer/octicons/build/svg/**/*.svg'), + ...themes, + }, + devtool: false, + output: { + path: resolve(__dirname, 'public'), + filename: 'js/[name].js', + chunkFilename: 'js/[name].js', + }, + node:{ + fs: 'empty' + }, + optimization: { + minimize: isProduction, + minimizer: [ + new TerserPlugin({ + sourceMap: true, + extractComments: false, + terserOptions: { + keep_fnames: /^(HTML|SVG)/, // https://github.com/fgnass/domino/issues/144 + output: { + comments: false, + }, + }, + }), + new OptimizeCSSAssetsPlugin({ + cssProcessor: cssnano, + cssProcessorOptions: { + parser: PostCSSSafeParser, + }, + cssProcessorPluginOptions: { + preset: [ + 'default', + { + discardComments: { + removeAll: true, + }, + }, + ], + }, + }), + ], + splitChunks: { + chunks: 'async', + name: (_, chunks) => chunks.map((item) => item.name).join('-'), + cacheGroups: { + // this bundles all monaco's languages into one file instead of emitting 1-65.js files + monaco: { + test: /monaco-editor/, + name: 'monaco', + chunks: 'async' + } + } + } + }, + module: { + rules: [ + { + test: /\.vue$/, + exclude: /node_modules/, + loader: 'vue-loader', + }, + { + test: require.resolve('jquery-datetimepicker'), + use: 'imports-loader?define=>false,exports=>false', + }, + { + test: /\.worker\.js$/, + exclude: /monaco/, + use: [ + { + loader: 'worker-loader', + options: { + name: '[name].js', + inline: true, + fallback: false, + }, + }, + ], + }, + { + test: /\.ts$/, + use: [ + { + loader: "ts-loader", + } + ], + exclude: /node_modules/ + }, + { + test: /\.js$/, + exclude: /node_modules/, + use: [ + { + loader: 'babel-loader', + options: { + cacheDirectory: true, + cacheCompression: false, + cacheIdentifier: [ + resolve(__dirname, 'package.json'), + resolve(__dirname, 'package-lock.json'), + resolve(__dirname, 'webpack.config.js'), + ].map((path) => statSync(path).mtime.getTime()).join(':'), + sourceMaps: true, + presets: [ + [ + '@babel/preset-env', + { + useBuiltIns: 'usage', + corejs: 3, + }, + ], + ], + plugins: [ + [ + '@babel/plugin-transform-runtime', + { + regenerator: true, + } + ], + '@babel/plugin-proposal-object-rest-spread', + ], + }, + }, + ], + }, + { + test: /\.(less|css)$/i, + use: [ + { + loader: MiniCssExtractPlugin.loader, + }, + { + loader: 'css-loader', + options: { + importLoaders: 2, + url: (_url, resourcePath) => { + // only resolve URLs for dependencies + return resourcePath.includes('node_modules'); + }, + } + }, + { + loader: 'postcss-loader', + options: { + plugins: () => [ + PostCSSPresetEnv(), + ], + }, + }, + { + loader: 'less-loader', + }, + ], + }, + { + test: /\.svg$/, + use: [ + { + loader: 'svg-sprite-loader', + options: { + extract: true, + spriteFilename: 'img/svg/icons.svg', + symbolId: (path) => { + const {name} = parse(path); + if (/@primer[/\\]octicons/.test(path)) { + return `octicon-${name}`; + } + return name; + }, + }, + }, + { + loader: 'svgo-loader', + }, + ], + }, + { + test: /\.(ttf|woff2?)$/, + use: [ + { + loader: 'file-loader', + options: { + name: '[name].[ext]', + outputPath: 'fonts/', + publicPath: (url) => `../fonts/${url}`, // seems required for monaco's font + }, + }, + ], + }, + ], + }, + plugins: [ + new VueLoaderPlugin(), + // avoid generating useless js output files for css- and svg-only chunks + new FixStyleOnlyEntriesPlugin({ + extensions: ['less', 'scss', 'css', 'svg'], + silent: true, + }), + new MiniCssExtractPlugin({ + filename: 'css/[name].css', + chunkFilename: 'css/[name].css', + }), + //new SourceMapDevToolPlugin({ + //filename: 'js/[name].js.map', + //include: [ + //'js/index.js', + //], + //}), + new SpriteLoaderPlugin({ + plainSprite: true, + }), + new MonacoWebpackPlugin({ + filename: 'js/monaco-[name].worker.js', + }) + ], + performance: { + hints: false, + maxEntrypointSize: Infinity, + maxAssetSize: Infinity, + }, + resolve: { + symlinks: false, + alias: { + vue$: 'vue/dist/vue.esm.js', // needed because vue's default export is the runtime only + }, + extensions: ['.tsx', '.ts', '.js'] + }, + watchOptions: { + ignored: [ + 'node_modules/**', + ], + }, + stats: { + children: false, + }, +};