Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
coverage/
node_modules/
tmp/
.nyc_output/
npm-debug.log
package-lock.json
Expand Down
22 changes: 10 additions & 12 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,16 @@ var build = () => {
'utf8'
)

// update slugify
var source =
fs.readFileSync(path.resolve(__dirname, '../slugify.js'), 'utf8')
.replace(
/var charMap = JSON\.parse\(.*\)/,
`var charMap = JSON.parse('${JSON.stringify(sort(charmap)).replace(/'/g, '\\\'')}')`
)
.replace(
/var locales = JSON\.parse\(.*\)/,
`var locales = JSON.parse('${JSON.stringify(clean(locales))}')`
)
fs.writeFileSync(path.resolve(__dirname, '../slugify.js'), source, 'utf8')
// update locales.json in tmp folder
var tmpDir = path.resolve(__dirname, '../tmp');
if (!fs.existsSync(tmpDir)) {
fs.mkdirSync(tmpDir);
}
fs.writeFileSync(
path.resolve(tmpDir, 'locales.json'),
JSON.stringify(clean(locales), null, 2),
'utf8'
)
}

build()
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,25 @@
"coveralls": "^3.1.0",
"github-changes": "^2.0.3",
"mocha": "^7.2.0",
"nyc": "^15.1.0"
"nyc": "^15.1.0",
"rollup": "^1.32.1",
"@rollup/plugin-json": "^4.1.0"
},
"main": "./slugify.js",
"main": "./slugify.cjs.js",
"module": "./slugify.mjs",
"unpkg": "./slugify.js",
"jsdelivr": "./slugify.js",
"files": [
"LICENSE",
"README.md",
"slugify.d.ts",
"slugify.cjs.js",
"slugify.mjs",
"slugify.js"
],
"types": "slugify.d.ts",
"scripts": {
"build": "node bin/build",
"build": "node bin/build && npx rollup -c",
"build:changelog": "github-changes --owner simov --repository slugify --only-pulls --use-commit-body --date-format '(YYYY-MM-DD)' --file CHANGELOG.md --verbose",
"test:ci": "npx mocha --recursive",
"test:cov": "npx nyc --reporter=lcov --reporter=text-summary mocha -- --recursive",
Expand Down
19 changes: 19 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pkg from './package.json';
import json from '@rollup/plugin-json';

export default [
{
input: 'src/slugify.js',
output: [
{ file: pkg.main, format: 'cjs', exports: 'auto' },
{ file: pkg.module, format: 'esm', exports: 'auto' },
{ file: pkg.unpkg, format: 'umd', exports: 'auto', name: 'slugify' }
],
plugins: [
json({
compact: true,
namedExports: false
})
]
}
];
57 changes: 57 additions & 0 deletions slugify.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading