0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Serve files to core/built/assets/

- see core/client/lib/assets-delivery/index.js for how this is done
- Turn off ember-cli fingerprinting
- ember-cli 0.2.0; Update .npmignore
- Fallback to old version of ember-cli-sass due to lib-sass errors
- Keep ember-data at beta-14.1 until we find the dep that's breaking on snapshot.attr
- Fix release task to ignore blank lines in .npmignore
This commit is contained in:
Matt Enlow 2015-03-08 11:09:57 -06:00
parent c7535c42cf
commit 58635b3e0a
15 changed files with 84 additions and 51 deletions

View file

@ -13,7 +13,6 @@ content/apps/**
content/data/**
!content/data/README.md
node_modules/**
core/test/**
**/*.db*
*.db*
.sass*
@ -23,20 +22,12 @@ core/test/**
.jshintrc
*.iml
config.js
core/built/scripts/templates.js
core/built/scripts/vendor.js
core/built/scripts/templates.js
core/built/scripts/ghost.js
core/built/**/*.map
core/client/**
!core/client/assets/**
core/client/assets/sass/**
core/client/assets/css/**
!core/client/assets/css/ghost.min.css
core/client/docs/**
core/test/**
CONTRIBUTING.md
SECURITY.md
.travis.yml
*.html
!core/server/email-templates/**
bower_components/**
bower_components/**

View file

@ -31,6 +31,9 @@ var _ = require('lodash'),
return pattern.substr(1);
}
return '!' + pattern;
}).filter(function (pattern) {
// Remove empty patterns
return pattern !== '!';
});
}()),
@ -855,7 +858,7 @@ var _ = require('lodash'),
// `bower` does have some quirks, such as not running as root. If you have problems please try running
// `grunt init --verbose` to see if there are any errors.
grunt.registerTask('init', 'Prepare the project for development',
['shell:ember:init', 'shell:bower', 'update_submodules', 'default']);
['shell:ember:init', 'shell:bower', 'update_submodules', 'assets', 'default']);
// ### Basic Asset Building
// Builds and moves necessary client assets. Prod additionally builds the ember app.
@ -867,14 +870,14 @@ var _ = require('lodash'),
//
// Build assets and dev version of the admin app.
grunt.registerTask('default', 'Build JS & templates for development',
['assets', 'shell:ember:dev']);
['shell:ember:dev']);
// ### Production assets
// `grunt prod` - will build the minified assets used in production.
//
// It is otherwise the same as running `grunt`, but is only used when running Ghost in the `production` env.
grunt.registerTask('prod', 'Build JS & templates for production',
['assets', 'shell:ember:prod', 'uglify:prod', 'master-warn']);
['shell:ember:prod', 'uglify:prod', 'master-warn']);
// ### Live reload
// `grunt dev` - build assets on the fly whilst developing
@ -888,7 +891,7 @@ var _ = require('lodash'),
//
// Note that the current implementation of watch only works with casper, not other themes.
grunt.registerTask('dev', 'Dev Mode; watch files and restart server on changes',
['assets', 'bgShell:ember', 'express:dev', 'watch']);
['bgShell:ember', 'express:dev', 'watch']);
// ### Release
// Run `grunt release` to create a Ghost release zip file.
@ -901,7 +904,7 @@ var _ = require('lodash'),
' - Copy files to release-folder/#/#{version} directory\n' +
' - Clean out unnecessary files (travis, .git*, etc)\n' +
' - Zip files in release-folder to dist-folder/#{version} directory',
['init', 'assets', 'shell:ember:prod', 'uglify:release', 'clean:release', 'copy:release', 'shell:shrinkwrap', 'compress:release']);
['init', 'shell:ember:prod', 'uglify:release', 'clean:release', 'copy:release', 'shell:shrinkwrap', 'compress:release']);
};
// Export the configuration

View file

@ -1,11 +1,33 @@
/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app'),
isProduction = EmberApp.env() === 'production',
disabled = {enabled: false},
assetLocation,
app;
app = new EmberApp({
hinting: false,
sourcemaps: {enabled: false} // see https://github.com/ember-cli/ember-cli/issues/2912
});
assetLocation = function (fileName) {
if (isProduction) {
fileName = fileName.replace('.', '.min.');
}
return '/assets/' + fileName;
};
app = new EmberApp({
outputPaths: {
app: {
js: assetLocation('ghost.js')
// css: see config/environment.js (sassOptions)
},
vendor: {
js: assetLocation('vendor.js'),
css: assetLocation('vendor.css')
}
},
hinting: false,
fingerprint: disabled,
sourcemaps: disabled // see https://github.com/ember-cli/ember-cli/issues/2912
});
app.import('bower_components/loader.js/loader.js');
app.import('bower_components/jquery/dist/jquery.js');

View file

@ -39,15 +39,15 @@
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans:400,300,700" />
{{/unless}}
<link rel="stylesheet" href="{{asset "vendor.css" ghost="true"}}" />
<link rel="stylesheet" href="{{asset "ghost.css" ghost="true"}}" />
<link rel="stylesheet" href="{{asset "vendor.css" ghost="true" minifyInProduction="true"}}" />
<link rel="stylesheet" href="{{asset "ghost.css" ghost="true" minifyInProduction="true"}}" />
{{content-for 'head-footer'}}
</head>
<body>
{{content-for 'body'}}
<script src="{{asset "vendor.js" ghost="true"}}"></script>
<script src="{{asset "ghost.js" ghost="true"}}"></script>
<script src="{{asset "vendor.js" ghost="true" minifyInProduction="true"}}"></script>
<script src="{{asset "ghost.js" ghost="true" minifyInProduction="true"}}"></script>
{{content-for 'body-footer'}}

View file

@ -3,12 +3,11 @@
"dependencies": {
"codemirror": "4.0.1",
"Countable": "2.0.2",
"handlebars": "2.0.0",
"device": "git://github.com/matthewhudson/device.js#5347a275b66020a0d4dfe9aad81a488f8cce448d",
"ember": "1.10.0",
"ember-data": "1.0.0-beta.14.1",
"ember-load-initializers": "ember-cli/ember-load-initializers#0.0.2",
"ember-resolver": "~0.1.11",
"ember-resolver": "~0.1.12",
"ember-simple-auth": "0.7.2",
"fastclick": "1.0.0",
"google-caja": "5669.0.0",
@ -19,7 +18,7 @@
"jquery-ui": "1.10.4",
"jqueryui-touch-punch": "furf/jquery-ui-touch-punch",
"keymaster": "git://github.com/madrobby/keymaster#564ea42e07de40da8113a571f17ceae8802672ff",
"loader.js": "ember-cli/loader.js#1.0.1",
"loader.js": "ember-cli/loader.js#3.2.0",
"moment": "2.8.3",
"nanoscroller": "0.8.4",
"normalize-scss": "~3.0.1",

View file

@ -41,6 +41,9 @@ module.exports = function (environment) {
}
if (environment === 'production') {
ENV.sassOptions = {
outputFile: 'ghost.min.css'
};
}
return ENV;

View file

@ -1,8 +1,9 @@
module.exports = {
name: 'asset-delivery',
postBuild: function (results) {
var fs = this.project.require('fs-extra');
module.exports = {
name: 'asset-delivery',
postBuild: function (results) {
var fs = this.project.require('fs-extra');
fs.copySync(results.directory + '/index.html', '../server/views/default.hbs');
}
};
fs.copySync(results.directory + '/index.html', '../server/views/default.hbs');
fs.copySync('./dist/assets', '../built/assets');
}
};

View file

@ -20,20 +20,19 @@
"license": "MIT",
"devDependencies": {
"broccoli-asset-rev": "^2.0.0",
"broccoli-ember-hbs-template-compiler": "^1.6.1",
"ember-cli": "0.1.15",
"ember-cli-6to5": "^3.0.0",
"ember-cli-app-version": "0.3.1",
"ember-cli": "^0.2.0",
"ember-cli-app-version": "0.3.2",
"ember-cli-autoprefixer": "0.3.0",
"ember-cli-babel": "^4.1.0",
"ember-cli-content-security-policy": "0.3.0",
"ember-cli-dependency-checker": "0.0.7",
"ember-cli-dependency-checker": "0.0.8",
"ember-cli-htmlbars": "^0.7.4",
"ember-cli-ic-ajax": "0.1.1",
"ember-cli-inject-live-reload": "^1.3.0",
"ember-cli-mocha": "^0.4.2",
"ember-cli-sass": "3.1.0-beta",
"ember-cli-sass": "^3.0.6",
"ember-cli-uglify": "1.0.1",
"ember-data": "1.0.0-beta.14.1",
"ember-data": "^1.0.0-beta.14.1",
"ember-export-application-global": "^1.0.2",
"fs-extra": "0.16.3",
"glob": "^4.0.5"

View file

@ -176,7 +176,7 @@ ConfigManager.prototype.set = function (config) {
availableThemes: this._config.paths.availableThemes || {},
availableApps: this._config.paths.availableApps || {},
builtScriptPath: path.join(corePath, '/client/dist/assets/')
clientAssets: path.join(corePath, '/built/assets/')
},
theme: {
// normalise the URL by removing any trailing slash

View file

@ -10,7 +10,13 @@ var hbs = require('express-hbs'),
asset = function (context, options) {
var output = '',
isAdmin = options && options.hash && options.hash.ghost;
isAdmin,
minify;
if (options && options.hash) {
isAdmin = options.hash.ghost;
minify = options.hash.minifyInProduction;
}
output += config.paths.subdir + '/';
@ -24,6 +30,12 @@ asset = function (context, options) {
// Get rid of any leading slash on the context
context = context.replace(/^\//, '');
// replace ".foo" with ".min.foo" in production
if (utils.isProduction && minify) {
context = context.replace('.', '.min.');
}
output += context;
if (!context.match(/^favicon\.ico$/)) {

View file

@ -66,9 +66,16 @@ function initDbHashAndFirstRun() {
// any are missing.
function builtFilesExist() {
var deferreds = [],
location = config.paths.builtScriptPath,
location = config.paths.clientAssets,
fileNames = ['ghost.js', 'vendor.js', 'ghost.css', 'vendor.css'];
if (process.env.NODE_ENV === 'production') {
// Production uses `.min` files
fileNames = fileNames.map(function (file) {
return file.replace('.', '.min.');
});
}
function checkExist(fileName) {
var errorMessage = 'Javascript files have not been built.',
errorHelp = '\nPlease read the getting started instructions at:' +

View file

@ -243,7 +243,7 @@ setupMiddleware = function (blogAppInstance, adminApp) {
blogApp.use(configHbsForContext);
// Admin only config
blogApp.use('/ghost', express['static'](path.join(corePath, '/client/dist/assets'), {maxAge: utils.ONE_YEAR_MS}));
blogApp.use('/ghost', express['static'](config.paths.clientAssets, {maxAge: utils.ONE_YEAR_MS}));
// Force SSL
// NOTE: Importantly this is _after_ the check above for admin-theme static resources,

View file

@ -17,7 +17,7 @@
<meta http-equiv="cleartype" content="on">
<link rel="stylesheet" type='text/css' href='//fonts.googleapis.com/css?family=Open+Sans:400,300,700'>
<link rel="stylesheet" href="{{asset "css/ghost.min.css" ghost="true"}}">
<link rel="stylesheet" href="{{asset "ghost.css" ghost="true" minifyInProduction="true"}}" />
</head>
<body class="{{bodyClass}}">
<main role="main" id="main">

View file

@ -94,7 +94,7 @@ describe('Config', function () {
'lang',
'availableThemes',
'availableApps',
'builtScriptPath'
'clientAssets'
);
});

View file

@ -88,10 +88,6 @@
"grunt-express-server": "~0.4.19",
"grunt-jscs": "~1.2.0",
"grunt-mocha-cli": "~1.11.0",
<<<<<<< HEAD
"grunt-sass": "~0.18.0",
=======
>>>>>>> grunt init, dev
"grunt-shell": "~1.1.1",
"grunt-update-submodules": "~0.4.1",
"matchdep": "~0.3.0",