-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: use rollup to build vendor/autoprefixer.js
- Loading branch information
Showing
8 changed files
with
19,515 additions
and
67,292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ | |
pkg/ | ||
|
||
.bundle | ||
*.lock | ||
Gemfile.lock | ||
|
||
build/node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import postcss from 'postcss' | ||
import autoprefixer from 'autoprefixer' | ||
|
||
export default { | ||
process: (css, processOptions, pluginOptions) => { | ||
// execjs does not support passing callback from ruby, | ||
// which makes waiting for the promise to settle from async function impossible | ||
var result = postcss([autoprefixer(pluginOptions)]).process(css, processOptions) | ||
|
||
var warns = result.warnings().map(function (i) { | ||
delete i.plugin | ||
return i.toString() | ||
}) | ||
|
||
var map = result.map ? result.map.toString() : null | ||
return { css: result.css, map: map, warnings: warns } | ||
}, | ||
|
||
info: (options) => { | ||
return autoprefixer(options).info() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "build", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"browser": true, | ||
"dependencies": { | ||
"autoprefixer": "postcss/autoprefixer", | ||
"nop": "^1.0.0", | ||
"postcss": "postcss/postcss#ose", | ||
"synchronous-promise": "^2.0.13", | ||
"yarn": "^1.22.5" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-alias": "^3.1.1", | ||
"@rollup/plugin-commonjs": "^15.0.0", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"@rollup/plugin-replace": "^2.3.3", | ||
"rollup": "^2.26.10", | ||
"rollup-plugin-node-polyfills": "^0.2.1" | ||
}, | ||
"resolutions": { | ||
"autoprefixer/postcss": "postcss/postcss#ose" | ||
}, | ||
"scripts": { | ||
"build": "yarn run rollup -c rollup.config.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import path from 'path' | ||
import alias from '@rollup/plugin-alias' | ||
import nodeResolve from '@rollup/plugin-node-resolve' | ||
import commonjs from '@rollup/plugin-commonjs' | ||
import json from '@rollup/plugin-json' | ||
import nodePolyfills from 'rollup-plugin-node-polyfills' | ||
import replace from '@rollup/plugin-replace' | ||
|
||
export default { | ||
input: 'autoprefixer.js', | ||
output: { | ||
file: '../vendor/autoprefixer.js', | ||
format: 'iife', | ||
name: 'autoprefixer', | ||
sourcemap: 'inline' | ||
}, | ||
plugins: [ | ||
// this line slips into browser build, patch for now | ||
replace({ | ||
"terminalHighlight.registerInput(Input)": '', | ||
include: "node_modules/postcss/lib/input.js", | ||
delimiters: ['', ''] | ||
}), | ||
json(), | ||
alias({ | ||
entries: [ | ||
{ find: '@babel/register', replacement: 'nop' }, | ||
{ find: '@babel/core', replacement: 'nop' }, | ||
{ find: 'url', replacement: path.resolve(__dirname, 'url.js') } | ||
] | ||
}), | ||
commonjs({ | ||
transformMixedEsModules: true | ||
}), | ||
nodeResolve({ | ||
browser: true, | ||
preferBuiltins: false, | ||
extensions: [".mjs", ".js", ".json", ".node", ".es6"] | ||
}), | ||
nodePolyfills() | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = Object.assign( | ||
{}, | ||
require("rollup-plugin-node-polyfills/polyfills/url.js"), | ||
{ | ||
pathToFileURL: (path)=> { return `file:///${encodeURIComponent(path)}` }, | ||
fileURLToPath: (fileURL)=> { return decodeURIComponent(fileURL.repalce(/^file:\/\/\//, '')) } | ||
} | ||
) |
Oops, something went wrong.