I am trying to automate uploading files to an S3 bucket by using: https://github.com/jpillora/grunt-aws#the-s3-task
My Gruntfile.js "compiles" correctly, but when executed it simply hangs when it gets to the S3 portion -- without errors.
The following is my Gruntfile.js:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
aws: grunt.file.readJSON('aws.json'),
concat: {
options: {
separator: '\n',
stripBanners: {
block: true
}
},
scripts: {
src: [
'scripts/bootstrap.js',
'scripts/bootstrap-select.js',
'scripts/bootbox.js',
'scripts/app.js',
'scripts/jquery.validate.js',
'scripts/additional-methods.js',
'scripts/captcha.js',
'scripts/mail.js',
'scripts/render.js'
],
dest: 'scripts/bundle.js'
},
style: {
src: [
'style/jquery-ui.css',
'style/bootstrap.css',
'style/bootstrap-select.css',
'style/en-us.css'
],
dest: 'style/bundle.css'
}
},
uglify: {
options: {
banner: '/*! <%= grunt.template.today("dd-mm-yyyy") %> */\n',
mangle: {
except: ['jQuery']
}
},
scripts: {
files: {
'scripts/bundle.min.js': 'scripts/bundle.js'
}
}
},
cssmin: {
target: {
files: [{
expand: true,
cwd: 'style',
src: ['bundle.css'],
dest: 'style',
ext: '.min.css'
}]
}
},
s3: {
options: {
accessKeyId: '<%= aws.key %>',
secretAccessKey: '<%= aws.secret %>',
bucket: '<%= aws.bucket %>',
region: '<%= aws.region %>',
access: 'public-read'
},
upload: {
headers: {
CacheControl: 604800,
Expires: new Date(Date.now() + 604800000).toUTCString()
},
cwd: "/",
src: "**"
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-aws');
grunt.registerTask('default', ['concat', 'uglify', 'cssmin', 's3']);
};
The associated output of sudo grunt s3 -v --force is as follows:
Loading "cloudfront.js" tasks...OK
+ cloudfront Loading "route53.js" tasks...OK
+ route53 Loading "s3.js" tasks...OK
+ s3 Loading "aws.js" tasks...OK
No tasks were registered or unregistered. Loading "cache-mgr.js" tasks...OK
No tasks were registered or unregistered. Loading "Gruntfile.js" tasks...OK
+ default
Running tasks: s3
Running "s3" task
Running "s3:upload" (s3) task Verifying property s3.upload exists in
config...OK
At that point, it hangs...
Any ideas?
The issue was with this line: cwd: "/"
It should have been cwd: "."
Related
I configured my PWA manifest.json in vue.config.js, shown below. How can I configure the PWA icons to refer to the images inside the assets/ folder?
module.exports = {
pwa: {
manifestOptions: {
name: process.env.VUE_APP_APP_NAME,
short_name: process.env.VUE_APP_SHORT_NAME,
start_url: process.env.VUE_APP_START_URL,
display: 'standalone',
theme_color: process.env.VUE_APP_PRIMARY_COLOR,
background_color: process.env.VUE_APP_BACKGROUND_COLOR,
icons: [
{
src: `src/assets/${process.env.VUE_APP_COMPANY}/logo-192x192.png`,
sizes: "192x192",
type: "image/png"
},
{
src: `src/assets/${process.env.VUE_APP_COMPANY}/logo-512x512.png`,
sizes: "512x512",
type: "image/png"
}
]
}
}
}
When I run my app, I get this error :
http://localhost:8080/src/assets/company/logo-512x512.png (Download error or resource isn't a valid image)
I don't understand why /src is set in the URL.
Use static assets from the public directory (e.g., public/img/company/logo-192x192.png and public/img/company/logo-512x512.png), which are copied as-is to the build output. Then your vue.config.js would reference them like this:
// vue.config.js
module.exports = {
pwa: {
manifestOptions: {
icons: [
{
src: `/img/${process.env.VUE_APP_COMPANY}/logo-192x192.png`,
sizes: "192x192",
type: "image/png"
},
{
src: `/img/${process.env.VUE_APP_COMPANY}/logo-512x512.png`,
sizes: "512x512",
type: "image/png"
}
]
}
}
}
I try to configure my environment to run tests on node.
This my my webpack.config.test.js
const serverConfig = {
module: {
loaders: [
{test: /\.tsx?$/, loader: 'ts-loader' }
]
},
target: 'node',
externals:[nodeExternals()],
resolve: {
extensions: ['.ts', '.tsx', '.js']
}
};
module.exports = serverConfig;
karma.config.js
// Karma configuration
// Generated on Tue Jun 27 2017 07:20:43 GMT-0500 (Hora est. PacĂfico, SudamĂ©rica)
const webpackConfig=require('./config/webpack/webpack.test');
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['mocha','es6-shim'],
plugins:[
require("karma-es6-shim"),
'karma-webpack',
'karma-jsdom-launcher',
'karma-mocha',
'karma-spec-reporter',
'karma-jsdom-launcher',
'karma-coverage',
'karma-chrome-launcher',
"karma-phantomjs-launcher",
'karma-htmlfile-reporter'
],
files: [
'test/**/*.spec.ts'
],
coverageReporter: {
webpackMiddleware: {
stats: "errors-only"
},
dir: 'build/coverage/',
reporters: [
{ type: 'html' },
{ type: 'text' },
{ type: 'text-summary' }
]
},
// list of files to exclude
exclude: [
],
preprocessors: {
'test/**/*.spec.ts':["webpack","coverage"]
},
webpack:webpackConfig,
reporters: ['spec','progress','html'],
htmlReporter: {
outputFile: 'tests/units.html',
// Optional
pageTitle: 'Unit Tests',
subPageTitle: 'A sample project description',
groupSuites: true,
useCompactStyle: true,
useLegacyStyle: true
},
// web server port
port: 9876,
colors: true,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: false,
concurrency: Infinity
})
}
test1
import { DBCONFIG } from './../src/config/db.config';
import { CONEXION } from './../src/config/database/mongo';
import { expect } from 'chai';
describe("#DATABASE",()=>{
it("Esta conectado",()=>{
CONEXION("hola",DBCONFIG.MONGO_URL_LOCAL)
.then(()=>{
expect(1).to.be("1");
})
.catch((e)=>{
expect(1).to.be(e);
})
})
});
test2
import { expect } from 'chai';
describe("#User",()=>{
it("use2r",()=>{
expect(1).to.equal("1");
})
})
When I run mocha + webpack with mocha-webpack, there is no problem the tests are running.
package.json
"test-server": "mocha-webpack --timeout 1000 --webpack-config config/webpack/webpack.test.js test/**/*.spec.ts",
"test":"karma start"
When I do it from karma depending on which browser I use to display the messages I throw similar errors, when I throw it with jsdom or PhantomJS I throw the following
require is not defined o Cannot find
Looking in git, the only answer that solved the problem, is to put in the processors of karma the following.
'test/**/*.spec.ts':["webpack","coverage"]
It is the same way and I have varied, but the error continues.
how can include node-sass-json-importer ?
i try to include node-sass-json-importer in includepaths in array way, with concat but no resuls...any idea? thanks for help
module.exports = {
dev: {
options: {
loadPath:['/'],
sourceMap:false,
style:'expanded',
includePaths:require('node-bourbon').with('../node_modules/node-bourbon'),
},
files: [{
expand: true,
cwd: 'patternlab/scss',
src: ['**/*.scss'],
dest: 'patternlab/source/css',
extDot: 'last',
ext: '.css'
}]
}
I'd like to generate sourcemaps for jsx files that are transpiled with babelify and browserify. It seems that some sourcemaps are being generated as a base64 encoded comment at the bottom of my output file, but stacktraces do not honor them.
My grunt task looks like the following:
browserify: {
options: {
browserifyOptions: {
debug: true
},
debug: true,
transform: ['babelify']
},
app: {
src: 'src/app.jsx',
dest: 'dist/app.js'
}
},
This works for me:
browserify: {
dev: {
options: {
browserifyOptions: {
debug: true
},
transform: [["babelify"]]
},
files: {
"dist/bundle.js": "src/index.js"
}
}
},
Going to need to use grunt-exorcise to extract the map from the bundle.
Browserify recommends it
browserify: {
options: {
browserifyOptions: {
debug: true
},
debug: true,
transform: ['babelify']
},
app: {
src: 'src/app.jsx',
dest: 'dist/app.js'
}
},
exorcise: {
app: {
options: {},
files: {
'dist/app.js.map':['dist/app.js'],
}
}
},
I have a LESS file (test.less) with the following class:
.bad_class {
color: #fff
}
I linting and compiling my files with the grunt-recess plugin.
My Grunt options for recess are:
recess: {
options: {
noUnderscores: true
},
test: {
files: {
'assets/css/test.css': [
'assets/less/test.less'
]
}
}
}
When I run recess, it doesn't fail.
I tried without setting the noUnderscores option at all - didn't work.
I even tried setting noUnderscores: false, but that didn't work.
What's am I doing wrong?
Try this
recess: {
build: {
src: [ 'assets/less/test.less' ],
dest: 'assets/css/test.css',
options: {
compile: true,
compress: true,
noUnderscores: false,
noIDs: false,
zeroUnits: false
}
}
}
If above is not working try the below code
recess: {
build: {
src: [ 'assets/less/test.less' ],
dest: 'assets/css/test.css',
options: {
compress: false,
noUnderscores: false,
noIDs: false,
zeroUnits: false
}
},
compliefile:{
src: [ 'assets/less/test.less' ],
dest: 'assets/css/test.css',
options: {
compile: true
}
}
}