96 lines
2.3 KiB
JavaScript
96 lines
2.3 KiB
JavaScript
|
var path = require('path');
|
||
|
|
||
|
var underscore = require('underscore');
|
||
|
var webpack = require('webpack');
|
||
|
|
||
|
var defs = require('./package.defs.js');
|
||
|
|
||
|
var distWebpackConfig = require('./webpack.dist.js');
|
||
|
var exampleWebpackConfig = require('./webpack.example.js');
|
||
|
|
||
|
module.exports = function (grunt) {
|
||
|
grunt.loadNpmTasks('grunt-contrib-clean');
|
||
|
grunt.loadNpmTasks('grunt-contrib-sass');
|
||
|
grunt.loadNpmTasks('grunt-karma');
|
||
|
grunt.loadNpmTasks('grunt-webpack');
|
||
|
grunt.loadNpmTasks('gruntify-eslint');
|
||
|
|
||
|
grunt.initConfig({
|
||
|
clean: {
|
||
|
options: {
|
||
|
force: true
|
||
|
},
|
||
|
all: [
|
||
|
defs.LIB_DIR,
|
||
|
path.resolve(defs.EXAMPLE_ASSETS_DIR, 'example.js'),
|
||
|
path.resolve(defs.EXAMPLE_ASSETS_DIR, 'example.js.map'),
|
||
|
path.resolve(defs.EXAMPLE_ASSETS_DIR, 'example.css'),
|
||
|
path.resolve(defs.EXAMPLE_ASSETS_DIR, 'example.css.map')
|
||
|
]
|
||
|
},
|
||
|
eslint: {
|
||
|
example: {
|
||
|
src: ['./example/example.js']
|
||
|
},
|
||
|
sources: {
|
||
|
src: ['./src/**/*.js']
|
||
|
},
|
||
|
tests: {
|
||
|
src: ['./tests/**/*.spec.js']
|
||
|
},
|
||
|
tools: {
|
||
|
src: [
|
||
|
'./Gruntfile.js', './karma.conf.js', './package.defs.js',
|
||
|
'./webpack.dist.js', './webpack.example.js'
|
||
|
]
|
||
|
}
|
||
|
},
|
||
|
karma: {
|
||
|
options: {
|
||
|
configFile: 'karma.conf.js'
|
||
|
},
|
||
|
dist: {
|
||
|
browsers: ['ChromiumHeadless'],
|
||
|
reporters: ['progress'],
|
||
|
singleRun: true,
|
||
|
webpackMiddleware: {
|
||
|
noInfo: true,
|
||
|
stats: 'errors-only'
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
sass: {
|
||
|
dist: {
|
||
|
src: [path.resolve(defs.SRC_DIR, 'Popup.scss')],
|
||
|
dest: path.resolve(defs.LIB_DIR, defs.CSS_FILENAME_DIST),
|
||
|
options: {
|
||
|
precision: 10,
|
||
|
sourcemap: 'auto',
|
||
|
style: 'compressed'
|
||
|
}
|
||
|
},
|
||
|
example: {
|
||
|
src: [path.resolve(defs.EXAMPLE_DIR, 'example.scss')],
|
||
|
dest: path.resolve(defs.EXAMPLE_ASSETS_DIR, 'example.css'),
|
||
|
options: {
|
||
|
precision: 10,
|
||
|
sourcemap: 'auto',
|
||
|
style: 'expanded'
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
webpack: {
|
||
|
dist: distWebpackConfig,
|
||
|
example: exampleWebpackConfig
|
||
|
}
|
||
|
});
|
||
|
|
||
|
grunt.registerTask('dist', [
|
||
|
'clean', 'eslint', 'karma:dist', 'sass:dist', 'webpack:dist'
|
||
|
]);
|
||
|
|
||
|
grunt.registerTask('example', [
|
||
|
'clean', 'sass:example', 'webpack:dist', 'webpack:example'
|
||
|
]);
|
||
|
};
|