From 7661a34b27392fdf0bc2c821f3a181219a798648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Ramos?= Date: Mon, 31 Oct 2016 14:24:31 +0000 Subject: [PATCH] static subfolders for easier static hosting --- ui/static/.gitignore | 5 +++-- ui/static/css/.gitignore | 4 ++++ ui/static/{ => css}/reboot.css | 0 ui/static/{ => css}/theme.css | 0 ui/static/index.html | 8 ++++---- ui/static/js/.gitkeep | 0 ui/webpack/base.js | 6 +++--- ui/webpack/development.js | 7 +++++-- ui/webpack/embed-markdown-loader/src/compile/compile.js | 5 +++-- ui/webpack/production.js | 3 ++- 10 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 ui/static/css/.gitignore rename ui/static/{ => css}/reboot.css (100%) rename ui/static/{ => css}/theme.css (100%) create mode 100644 ui/static/js/.gitkeep diff --git a/ui/static/.gitignore b/ui/static/.gitignore index e736ca10..d895d0f1 100644 --- a/ui/static/.gitignore +++ b/ui/static/.gitignore @@ -1,6 +1,7 @@ * !.gitignore -!theme.css +!.gitkeep !index.html -!reboot.css +js/* +!js/.gitkeep diff --git a/ui/static/css/.gitignore b/ui/static/css/.gitignore new file mode 100644 index 00000000..7629cd5b --- /dev/null +++ b/ui/static/css/.gitignore @@ -0,0 +1,4 @@ +* +!.gitignore +!theme.css +!reboot.css diff --git a/ui/static/reboot.css b/ui/static/css/reboot.css similarity index 100% rename from ui/static/reboot.css rename to ui/static/css/reboot.css diff --git a/ui/static/theme.css b/ui/static/css/theme.css similarity index 100% rename from ui/static/theme.css rename to ui/static/css/theme.css diff --git a/ui/static/index.html b/ui/static/index.html index d10c4d51..81611149 100644 --- a/ui/static/index.html +++ b/ui/static/index.html @@ -2,12 +2,12 @@ Joyent UI Framework - - - + + +
- + diff --git a/ui/static/js/.gitkeep b/ui/static/js/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/ui/webpack/base.js b/ui/webpack/base.js index 14de50e5..c7618fe4 100644 --- a/ui/webpack/base.js +++ b/ui/webpack/base.js @@ -6,7 +6,7 @@ const cssFunctions = require('../src/shared/functions'); const plugins = { 'no-errors-plugin': new webpack.NoErrorsPlugin(), 'extract-text-plugin': new ExtractTextPlugin({ - filename: '[name].css', + filename: 'css/[name].css', allChunks: true }), 'loader-options-plugin': new webpack.LoaderOptionsPlugin({ @@ -33,8 +33,8 @@ exports.config = { context: path.join(__dirname, '../'), output: { path: path.join(__dirname, '../static'), - publicPath: '/static/', - filename: '[name].js' + publicPath: '/', + filename: 'js/[name].js' }, plugins: [ plugins['no-errors-plugin'], diff --git a/ui/webpack/development.js b/ui/webpack/development.js index d4cb0e09..7f31e3d2 100644 --- a/ui/webpack/development.js +++ b/ui/webpack/development.js @@ -1,14 +1,17 @@ const pkg = require('../package.json'); const base = require('./base.js'); const webpack = require('webpack'); +const path = require('path'); const devServer = { + contentBase: [ + path.join(__dirname, '../static/') + ], hot: true, compress: true, lazy: false, - publicPath: '/static/', historyApiFallback: { - index: './static/index.html' + index: './index.html' } }; diff --git a/ui/webpack/embed-markdown-loader/src/compile/compile.js b/ui/webpack/embed-markdown-loader/src/compile/compile.js index 59da11f8..ffc1d56b 100644 --- a/ui/webpack/embed-markdown-loader/src/compile/compile.js +++ b/ui/webpack/embed-markdown-loader/src/compile/compile.js @@ -82,11 +82,12 @@ module.exports = ({ return fn(err); } - let style = mfs.readdirSync('/static').filter((file) => { + // TODO read extract css defs + let style = mfs.readdirSync('/static/css').filter((file) => { return /\.css$/.test(file); }).map((file) => { try { - return mfs.readFileSync(`/static/${file}`, 'utf-8'); + return mfs.readFileSync(`/static/css/${file}`, 'utf-8'); } catch (err) { return ''; } diff --git a/ui/webpack/production.js b/ui/webpack/production.js index 02c90d18..788fee06 100644 --- a/ui/webpack/production.js +++ b/ui/webpack/production.js @@ -2,10 +2,11 @@ const WebpackShellPlugin = require('webpack-shell-plugin'); const base = require('./base.js'); const webpack = require('webpack'); const entries = require('./entrypoints'); +const path = require('path'); module.exports = Object.assign(base.config, { entry: entries.reduce((all, entry) => { - all[entry.name] = [entry.path]; + all[entry.name] = [`./${path.relative(base.config.context, entry.path)}`]; return all; }, {}), plugins: base.config.plugins.concat([