-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e4dbff
commit 3e4275c
Showing
10 changed files
with
680 additions
and
2 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
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
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
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,38 @@ | ||
// Based on CRA build script | ||
|
||
// Do this as the first thing so that any code reading it knows the right env. | ||
process.env.BABEL_ENV = 'production' | ||
process.env.NODE_ENV = 'production' | ||
|
||
const webpack = require('webpack') | ||
const webpackConfigFactory = require('./webpack.config') | ||
|
||
module.exports = async ({ paths }) => { | ||
console.log('Building plugin...') | ||
|
||
const webpackConfig = webpackConfigFactory({ env: 'production', paths }) | ||
const compiler = webpack(webpackConfig) | ||
return new Promise((resolve, reject) => { | ||
compiler.run(err => { | ||
if (err) { | ||
if (!err.message) { | ||
reject(err) | ||
return | ||
} | ||
|
||
let errMessage = err.message | ||
// Add additional information for postcss errors | ||
if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) { | ||
errMessage += | ||
'\nCompileError: Begins at CSS selector ' + | ||
err['postcssNode'].selector | ||
} | ||
|
||
reject(new Error(errMessage)) | ||
return | ||
} | ||
|
||
resolve() | ||
}) | ||
}) | ||
} |
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,17 @@ | ||
const build = require('./build') | ||
const start = require('./start') | ||
|
||
module.exports = ({ config, paths }) => ({ | ||
// build: () => build({ config, paths }), | ||
build: async () => { | ||
try { | ||
await build({ config, paths }) | ||
} catch (error) { | ||
console.log('\n\nerror building plugin:') | ||
console.error(error) | ||
console.log('\n') | ||
throw error | ||
} | ||
}, | ||
start: ({ port }) => start({ port, config, paths }), | ||
}) |
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,3 @@ | ||
// TODO | ||
// module.exports = ({ port, config, paths }) => {} | ||
module.exports = () => {} |
Oops, something went wrong.