Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting rid of build warnings #110

Merged
merged 1 commit into from
Feb 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "Jordan Scales <[email protected]>",
"devDependencies": {
"accessibility-developer-tools": "2.9.0-rc.0",
"autoprefixer-loader": "^2.0.0",
"autoprefixer": "^6.5.3",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to configure autoprefixing within postcss now? It seems some properties like align-items are not being prefixed. Can you confirm?

image

For reference, here's how .tota11y-plugin-switch is defined currently on master:

image

"babel": "^5.6.7",
"babel-core": "^5.0.12",
"babel-loader": "^5.0.0",
Expand All @@ -22,17 +22,17 @@
"less": "^2.5.0",
"less-loader": "^2.2.0",
"mocha": "^2.2.5",
"postcss": "^4.1.11",
"postcss-loader": "^0.4.3",
"postcss": "^5.2.6",
"postcss-loader": "^1.1.1",
"script-loader": "^0.6.1",
"style-loader": "^0.10.1",
"webpack": "^1.8.4",
"webpack-dev-server": "^1.9.0"
},
"scripts": {
"build": "npm run prod && npm run dev",
"prod": "webpack --config webpack.config.babel.js -p",
"dev": "webpack --config webpack.config.babel.js -d --devtool hidden --output-file=tota11y.js",
"prod": "NODE_ENV=production webpack --config webpack.config.babel.js",
"dev": "webpack --config webpack.config.babel.js -d --devtool hidden --output-filename=tota11y.js",
"lint": "eslint index.js plugins test utils",
"test": "mocha --require test/babel-hook test/*.js",
"live-test": "webpack-dev-server --config webpack.config.babel.js --hot --inline"
Expand Down
49 changes: 31 additions & 18 deletions webpack.config.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ let handlebars = require("handlebars");
let path = require("path");
let postcss = require("postcss");
let webpack = require("webpack");
let autoprefixer = require("autoprefixer");

let options = require("./utils/options");

// PostCSS plugin to append !important to every CSS rule
let veryimportant = postcss.plugin("veryimportant", function() {
return function(css) {
css.eachDecl(function(decl) {
css.walkDecls(function(decl) {
decl.important = true;
});
};
Expand All @@ -18,6 +19,30 @@ let veryimportant = postcss.plugin("veryimportant", function() {
let bannerTemplate = handlebars.compile(
fs.readFileSync("./templates/banner.handlebars", "utf-8"));

const plugins = [
// Add a banner to our bundles with a version number, date, and
// license info
new webpack.BannerPlugin(
bannerTemplate({
version: require("./package.json").version,
date: new Date().toISOString().slice(0, 10),
}),
{entryOnly: true}),

// Make the JSX pragma function available everywhere without the need
// to use "require"
new webpack.ProvidePlugin({
[options.jsxPragma]: path.join(__dirname, "utils", "element"),
}),
];

if (process.env.NODE_ENV === "production") {
plugins.push(
// Suppress uglifyJS warnings from node_modules/
new webpack.optimize.UglifyJsPlugin({compress: {warnings: false}})
)
}

module.exports = {
entry: {
app: "./index.js",
Expand All @@ -39,25 +64,13 @@ module.exports = {
{ test: /\.handlebars$/, loader: "handlebars", },
{
test: /\.less$/,
loader: "style!css!postcss!autoprefixer?{browsers:['> 1%']}!less",
loader: "style!css!postcss!less",
},
],
},
plugins: [
// Add a banner to our bundles with a version number, date, and
// license info
new webpack.BannerPlugin(
bannerTemplate({
version: require("./package.json").version,
date: new Date().toISOString().slice(0, 10),
}),
{entryOnly: true}),

// Make the JSX pragma function available everywhere without the need
// to use "require"
new webpack.ProvidePlugin({
[options.jsxPragma]: path.join(__dirname, "utils", "element"),
}),
plugins,
postcss: [
veryimportant,
autoprefixer({browsers: ["> 1%"]}),
],
postcss: [veryimportant],
};