diff --git a/CHANGELOG.md b/CHANGELOG.md index c53dbc2e..d0fcc2a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ - Modified notifications to not send on initial startup - Updated Incident UI - Added additional testing for notifications +- Modified SCSS/SASS files to be generated from 1, main.scss to main.css +- Modified index page to use /assets directory for assets, (main.css, style.css) +- Modified index page to use CDN asset paths # 0.90.61 (07-22-2020) - Modified sass layouts, organized and split up sections diff --git a/Makefile b/Makefile index 41008a04..002ecd09 100644 --- a/Makefile +++ b/Makefile @@ -136,7 +136,9 @@ frontend-build: @rm -rf source/dist && rm -rf frontend/dist @echo "yarn install and build static frontend" cd frontend && yarn && yarn build - @cp -r frontend/dist source/ && cp -r frontend/src/assets/scss source/dist/ + @cp -r frontend/dist source/ + @cp -r frontend/src/assets/scss source/dist/ + @cp -r frontend/public/main.scss source/dist/scss/ @cp -r source/tmpl/*.* source/dist/ @cp -r frontend/public/favicon source/dist/ @echo "Frontend build complete at ./source/dist" diff --git a/frontend/config/webpack.config.prod.js b/frontend/config/webpack.config.prod.js index f181627b..78107b08 100644 --- a/frontend/config/webpack.config.prod.js +++ b/frontend/config/webpack.config.prod.js @@ -60,6 +60,9 @@ const webpackConfig = merge(commonConfig, { plugins: [ new webpack.EnvironmentPlugin(environment), new CleanWebpackPlugin(), + new webpack.optimize.LimitChunkCountPlugin({ + maxChunks: 1 + }), new MiniCSSExtractPlugin({ filename: 'css/[name].css', chunkFilename: 'css/[name].css' diff --git a/frontend/public/base.gohtml b/frontend/public/base.gohtml index 07bf22ba..2eefa195 100644 --- a/frontend/public/base.gohtml +++ b/frontend/public/base.gohtml @@ -43,12 +43,9 @@ {{if USE_CDN}} - - {{else}} - {{if USING_ASSETS}} - + {{else if USING_ASSETS }} {{else}} @@ -66,10 +63,14 @@ {{if USE_CDN}} - +{{else if USING_ASSETS }} + + + + {{else}} <% _.each(htmlWebpackPlugin.tags.bodyTags, function(bodyTag) { %> <%= bodyTag %> <% }) %> diff --git a/frontend/public/main.scss b/frontend/public/main.scss new file mode 100644 index 00000000..fe1ad7d4 --- /dev/null +++ b/frontend/public/main.scss @@ -0,0 +1,6 @@ +@import 'variables'; +@import 'mixin'; +@import 'base'; +@import 'forms'; +@import 'layout'; +@import 'mobile'; diff --git a/source/source.go b/source/source.go index 9693e1d4..71d93ba9 100644 --- a/source/source.go +++ b/source/source.go @@ -49,21 +49,20 @@ func CompileSASS(files ...string) error { sassBin = bin } - for _, file := range files { - scssFile := filepath.Join(utils.Params.GetString("STATPING_DIR"), "assets", file) - log.Infoln(fmt.Sprintf("Compiling SASS %v into %v", scssFile, scssRendered(scssFile))) + scssFile := filepath.Join(utils.Params.GetString("STATPING_DIR"), "assets", "scss", "main.scss") + log.Infoln(fmt.Sprintf("Compiling SASS %v into %v", scssFile, scssRendered(scssFile))) - stdout, stderr, err := utils.Command(sassBin, scssFile, scssRendered(scssFile)) - if err != nil { - log.Errorln(fmt.Sprintf("Failed to compile assets with SASS %v", err)) - log.Errorln(fmt.Sprintf("%s %s %s", sassBin, scssFile, scssRendered(scssFile))) - return errors.Wrapf(err, "failed to compile assets, %s %s %s", err, stdout, stderr) - } - - if stdout != "" || stderr != "" { - log.Infoln(fmt.Sprintf("out: %v | error: %v", stdout, stderr)) - } + stdout, stderr, err := utils.Command(sassBin, scssFile, scssRendered(scssFile)) + if err != nil { + log.Errorln(fmt.Sprintf("Failed to compile assets with SASS %v", err)) + log.Errorln(fmt.Sprintf("%s %s %s", sassBin, scssFile, scssRendered(scssFile))) + return errors.Wrapf(err, "failed to compile assets, %s %s %s", err, stdout, stderr) } + + if stdout != "" || stderr != "" { + log.Infoln(fmt.Sprintf("out: %v | error: %v", stdout, stderr)) + } + log.Infoln("SASS Compiling is complete!") return nil } @@ -103,10 +102,10 @@ func SaveAsset(data []byte, path string) error { // OpenAsset returns a file's contents as a string func OpenAsset(path string) string { - path = fmt.Sprintf("%s/assets/%s", utils.Directory, path) + path = filepath.Join(utils.Directory, "assets", path) data, err := utils.OpenFile(path) if err != nil { - log.Errorln(fmt.Sprintf("Failed to open %v, %v", path, err)) + log.Errorln(fmt.Sprintf("Failed to open %s, %v", path, err)) return "" } return data @@ -114,7 +113,7 @@ func OpenAsset(path string) string { // CreateAllAssets will dump HTML, CSS, SCSS, and JS assets into the '/assets' directory func CreateAllAssets(folder string) error { - log.Infoln(fmt.Sprintf("Dump Statping assets into %v/assets", folder)) + log.Infoln(fmt.Sprintf("Dump Statping assets into %s/assets", folder)) fp := filepath.Join if err := MakePublicFolder(fp(folder, "/assets")); err != nil { diff --git a/source/source_test.go b/source/source_test.go index 2a418461..573f1390 100644 --- a/source/source_test.go +++ b/source/source_test.go @@ -25,12 +25,16 @@ func TestCore_UsingAssets(t *testing.T) { func TestCreateAssets(t *testing.T) { assert.Nil(t, CreateAllAssets(dir)) + assert.FileExists(t, dir+"/assets/js/bundle.js") assert.True(t, UsingAssets(dir)) assert.Nil(t, CompileSASS(DefaultScss...)) assert.FileExists(t, dir+"/assets/css/style.css") - assert.FileExists(t, dir+"/assets/css/vendor.css") + assert.FileExists(t, dir+"/assets/css/main.css") + assert.FileExists(t, dir+"/assets/scss/main.scss") assert.FileExists(t, dir+"/assets/scss/base.scss") + assert.FileExists(t, dir+"/assets/scss/forms.scss") assert.FileExists(t, dir+"/assets/scss/mobile.scss") + assert.FileExists(t, dir+"/assets/scss/layout.scss") assert.FileExists(t, dir+"/assets/scss/variables.scss") }