diff --git a/sapl-frontend/package.json b/sapl-frontend/package.json index 93ba56c6d..1f75d7e77 100644 --- a/sapl-frontend/package.json +++ b/sapl-frontend/package.json @@ -34,10 +34,6 @@ "@vue/cli-service": "^3.3.0", "babel-eslint": "^10.0.1", "css-loader": "^2.1.0", - "node-sass": "^4.9.0", - "sass-loader": "^7.0.1", - "vue-template-compiler": "^2.5.21", - "eslint": "^5.12.0", "eslint-config-standard": "^12.0.0", "eslint-friendly-formatter": "^4.0.1", @@ -46,6 +42,9 @@ "eslint-plugin-node": "^8.0.1", "eslint-plugin-promise": "^4.0.1", "eslint-plugin-standard": "^4.0.0", - "eslint-plugin-vue": "^5.1.0" + "eslint-plugin-vue": "^5.1.0", + "node-sass": "^4.9.0", + "sass-loader": "^7.0.1", + "vue-template-compiler": "^2.5.21" } } diff --git a/sapl-frontend/src/apps/compilacao/main.js b/sapl-frontend/src/apps/compilacao/main.js index 3dad801f3..caf9d3195 100644 --- a/sapl-frontend/src/apps/compilacao/main.js +++ b/sapl-frontend/src/apps/compilacao/main.js @@ -2,8 +2,6 @@ import './scss/compilacao.scss' -import 'bootstrap' - import compilacao from './js/old/compilacao' import compilacaoView from './js/old/compilacao_view' import compilacaoNotas from './js/old/compilacao_notas' diff --git a/sapl-frontend/src/global/functions.js b/sapl-frontend/src/global/functions.js index 745fd82b1..0059330cb 100644 --- a/sapl-frontend/src/global/functions.js +++ b/sapl-frontend/src/global/functions.js @@ -1,3 +1,6 @@ +window.jQuery = jQuery +window.$ = jQuery + window.getCookie = function (name) { var cookieValue = null if (document.cookie && document.cookie !== '') { diff --git a/sapl-frontend/src/global/main.js b/sapl-frontend/src/global/main.js index 008ae1d1c..7d4f83a5a 100644 --- a/sapl-frontend/src/global/main.js +++ b/sapl-frontend/src/global/main.js @@ -4,16 +4,14 @@ import 'jquery-mask-plugin' import 'webpack-jquery-ui/dialog' import 'webpack-jquery-ui/sortable' -import 'bootstrap' - import './functions' +import 'bootstrap' import './image_cropping' require('imports-loader?window.jQuery=jquery!./jquery.runner.js') - -window.jQuery = jQuery -window.$ = jQuery +// require(THEME_CUSTOM + '/src/assets/img/authenticated.png') window.autorModal() window.refreshMask() + diff --git a/sapl-frontend/vue.config.js b/sapl-frontend/vue.config.js index eb2f750b5..fadea7489 100644 --- a/sapl-frontend/vue.config.js +++ b/sapl-frontend/vue.config.js @@ -8,22 +8,24 @@ dotenv.config({ path: '../sapl/.env' }) var THEME_CUSTOM = process.env.THEME_CUSTOM === undefined ? 'sapl-oficial-theme' : process.env.THEME_CUSTOM module.exports = { - publicPath: 'http://localhost:8080/', + publicPath: process.env.NODE_ENV === 'production' ? '/static/' : 'http://localhost:8080/', outputDir: './dist/', + configureWebpack: { + devtool: 'cheap-module-eval-source-map', + }, + chainWebpack: config => { config.optimization .splitChunks(false) - + config .plugin('BundleTracker') .use(BundleTracker, [{ filename: './webpack-stats.json' }]) - - config.devtool = 'source-map' - + config.resolve.alias .set('__STATIC__', 'static') - + config.devServer .public('') .host('localhost') @@ -36,11 +38,50 @@ module.exports = { .contentBase([ path.join(__dirname, 'public'), path.join(__dirname, 'src', 'assets'), - path.join(__dirname, 'node_modules', THEME_CUSTOM, 'public') + //path.join(__dirname, 'node_modules', THEME_CUSTOM, 'public'), + //path.join(__dirname, 'node_modules', THEME_CUSTOM, 'src', 'assets') ]) + + config + .plugin('copy') + .tap(([options]) => { + options.push( + { + from: path.join(__dirname, 'node_modules', THEME_CUSTOM, 'public'), + to: path.join(__dirname, 'dist'), + toType: 'dir', + ignore: [ + '.DS_Store' + ] + }) + return [options] + }) - config.entryPoints.delete('app') + /* + new CopyWebpackPlugin( + [ + { + from: '/home/leandro/desenvolvimento/envs/sapl/sapl-frontend/public', + to: '/home/leandro/desenvolvimento/envs/sapl/sapl-frontend/dist', + toType: 'dir', + ignore: [ + '.DS_Store' + ] + } + ] + ), + config + .module + .rule('images') + .use('url-loader') + .loader('url-loader') + .tap(options => { + options.fallback.options.name = (process.env.NODE_ENV === 'production' + ? '/static/' + : '') + options.fallback.options.name + return options + }) */ config .plugin('provide') .use(require('webpack/lib/ProvidePlugin'), [{ @@ -50,25 +91,28 @@ module.exports = { jQuery: 'jquery', _: 'lodash' }]) - - config.entry(THEME_CUSTOM) + config.entryPoints.delete('app') + + config + .entry(THEME_CUSTOM) .add('./src/theme-dev/main.js') // .add(THEME_CUSTOM + '/src/main.js') .end() - - config.entry('global') + + config + .entry('global') .add('./src/global/main.js') .end() - + config.entry('compilacao') - .add('./src/apps/compilacao/main.js') - .end() - + .add('./src/apps/compilacao/main.js') + .end() + /* config - .plugin('theme') - .use(webpack.DefinePlugin, [{ - THEME_CUSTOM: JSON.stringify(THEME_CUSTOM) - }]) - .end() */ + .plugin('theme') + .use(webpack.DefinePlugin, [{ + THEME_CUSTOM: JSON.stringify(THEME_CUSTOM) + }]) + .end() */ } } diff --git a/sapl/settings.py b/sapl/settings.py index 55dbef8bb..08b00c85a 100755 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -264,32 +264,26 @@ LOCALE_PATHS = ( 'locale', ) - WEBPACK_LOADER = { 'DEFAULT': { 'CACHE': not DEBUG, - 'BUNDLE_DIR_NAME': 'bundle/dist/', + 'BUNDLE_DIR_NAME': 'dist/', 'STATS_FILE': FRONTEND_DIR.child('webpack-stats.json'), 'POLL_INTERVAL': 0.1, 'TIMEOUT': None, 'IGNORE': [r'.+\.hot-update.js', r'.+\.map'] } } + THEME_CUSTOM = config('THEME_CUSTOM', default='sapl-oficial-theme') -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/1.8/howto/static-files/ STATIC_URL = '/static/' STATIC_ROOT = PROJECT_DIR.child("collected_static") -# STATICFILES_DIRS = (BASE_DIR.child("static"),) - STATICFILES_DIRS = ( - # BASE_DIR.child("static"), FRONTEND_DIR.child('dist'), ) - STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder',