Skip to content

Commit

Permalink
Upgrade to Neutrino 8
Browse files Browse the repository at this point in the history
  • Loading branch information
constgen committed Jan 21, 2018
1 parent 1148270 commit a5e7a26
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 49 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
## Requirements

- Node.js v6.9+
- Neutrino v7
- Neutrino v8

## Installation

Expand Down Expand Up @@ -216,9 +216,9 @@ The following is a list of rules and their identifiers which can be overridden:
The following is a list of plugins and their identifiers which can be overridden:

- `env`: Injects the value of NODE_ENV into the application as process.env.NODE_ENV;
- `html`: Creates HTML files when building. Has various options that can be configured via package.json;
- `html`: Creates HTML files when building.
- `html-defer`: Adds `defer` attribute to `<script>` tags in HTML files when building;
- `chunk`: Defines chunks for manifest and vendor entry points. Can be configured via package.json;
- `chunk`: Defines chunks for manifest and vendor entry points.
- `hot`: Enables hot module reloading;
- `clean`: Clears the contents of build prior to creating a production bundle;
- `copy`: Copies files during build, defaults from `src/static` to `build/static`.
Expand All @@ -227,8 +227,7 @@ The following is a list of plugins and their identifiers which can be overridden
### Override configuration

By following the [customization guide](https://neutrino.js.org/customization) and knowing the rule, loader, and plugin IDs above,
you can override and augment the build by providing a function to your `.neutrinorc.js` use array. You can also
make these changes from the Neutrino API in custom middleware.
you can override and augment the build by providing a function to your `.neutrinorc.js` use array. You can also make these changes from the Neutrino API in a custom middleware.

#### Vendoring

Expand Down
46 changes: 23 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "neutrino-preset-svelte",
"version": "4.0.2",
"version": "5.0.0",
"description": "Neutrino preset for Svelte applications",
"main": "src/index.js",
"author": "Constantine Genchevsky <[email protected]>",
Expand All @@ -19,43 +19,43 @@
],
"scripts": {
"test": "npm run lint",
"lint": "eslint --ext .js src/ "
"lint": "eslint --ext .js src/"
},
"dependencies": {
"svelte": "~1.41.1",
"neutrino-middleware-svelte-loader": "~4.0.0",
"neutrino-middleware-chunk": "~7.2.1",
"neutrino-middleware-clean": "~7.2.1",
"neutrino-middleware-copy": "~7.2.1",
"neutrino-middleware-minify": "~7.2.1",
"neutrino-middleware-style-loader": "~7.2.1",
"neutrino-middleware-font-loader": "~7.2.1",
"neutrino-middleware-image-loader": "~7.2.1",
"neutrino-middleware-env": "~7.2.1",
"neutrino-middleware-hot": "~7.2.1",
"babel-polyfill": "6.23.0",
"core-js": "^2.4.0",
"deepmerge": "~2.0.0",
"svelte": "~1.53.0",
"neutrino-middleware-svelte-loader": "~4.1.0",
"@neutrinojs/chunk": "~8.0.18",
"@neutrinojs/clean": "~8.0.18",
"@neutrinojs/copy": "~8.0.18",
"@neutrinojs/minify": "~8.0.18",
"@neutrinojs/style-loader": "~8.0.18",
"@neutrinojs/font-loader": "~8.0.18",
"@neutrinojs/image-loader": "~8.0.18",
"@neutrinojs/env": "~8.0.18",
"@neutrinojs/hot": "~8.0.18",
"babel-polyfill": "6.26.0",
"core-js": "^2.5.0",
"deepmerge": "~2.0.1",
"arrify": "~1.0.1",
"opn": "~5.1.0",
"opn": "~5.2.0",
"babel-loader": "~7.1.2",
"babel-preset-env": "~1.6.1",
"babel-plugin-syntax-dynamic-import": "~6.18.0",
"babel-plugin-transform-object-rest-spread": "~6.26.0",
"babel-plugin-transform-class-properties": "~6.24.1",
"html-webpack-plugin": "~2.30.1",
"script-ext-html-webpack-plugin": "~1.8.5",
"script-ext-html-webpack-plugin": "~1.8.8",
"progress-bar-webpack-plugin": "~1.10.0",
"webpack": "^3.8.1",
"webpack-dev-server": "2.9.3",
"eslint-plugin-html": "~3.2.2",
"webpack": "^3.10.0",
"webpack-dev-server": "2.11.1",
"eslint-plugin-html": "~4.0.1",
"ip": "~1.1.5"
},
"devDependencies": {
"eslint": "^4.9.0"
"eslint": "^4.16.0"
},
"peerDependencies": {
"neutrino": "^7.0.0"
"neutrino": "^8.0.0"
},
"files": [
"src/*",
Expand Down
4 changes: 2 additions & 2 deletions src/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

let arrify = require('arrify')
let path = require('path')
let merge = require('deepmerge')
let deepmerge = require('deepmerge')

module.exports = function (neutrino, options = {}) {
const NODE_MODULES = path.resolve(__dirname, '../node_modules')
Expand Down Expand Up @@ -41,7 +41,7 @@ module.exports = function (neutrino, options = {}) {
.end()
.use('babel')
.loader(require.resolve('babel-loader'))
.tap((opts = {}) => merge(opts, {
.tap((opts = {}) => deepmerge(opts, {
presets: [
[require.resolve('babel-preset-env'), {
debug: false,
Expand Down
4 changes: 2 additions & 2 deletions src/dev-server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

let opn = require('opn')
let hot = require('neutrino-middleware-hot')
let hot = require('@neutrinojs/hot')
let ip = require('ip')

module.exports = function (neutrino, options = {}) {
Expand All @@ -27,7 +27,7 @@ module.exports = function (neutrino, options = {}) {
.headers({
host: publicHost
})
.public(publicHost) //.public(`${publicHost}:${port}`)
.public(publicHost) //.public(`${publicHost}:${port}`)
.publicPath('/')
.stats({
assets: false,
Expand Down
45 changes: 28 additions & 17 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

let path = require('path')
let svelte = require('neutrino-middleware-svelte-loader')
let chunk = require('neutrino-middleware-chunk')
let clean = require('neutrino-middleware-clean')
let copy = require('neutrino-middleware-copy')
let minify = require('neutrino-middleware-minify')
let styleLoader = require('neutrino-middleware-style-loader')
let fontLoader = require('neutrino-middleware-font-loader')
let imageLoader = require('neutrino-middleware-image-loader')
let env = require('neutrino-middleware-env')
let merge = require('deepmerge')
let chunk = require('@neutrinojs/chunk')
let clean = require('@neutrinojs/clean')
let copy = require('@neutrinojs/copy')
let minify = require('@neutrinojs/minify')
let styleLoader = require('@neutrinojs/style-loader')
let fontLoader = require('@neutrinojs/font-loader')
let imageLoader = require('@neutrinojs/image-loader')
let env = require('@neutrinojs/env')
let deepmerge = require('deepmerge')
let arrify = require('arrify')

let devServer = require('./dev-server.js')
Expand All @@ -28,6 +28,13 @@ module.exports = function (neutrino, options = {}) {
let lintRule = config.module.rules.get('lint')
let eslintLoader = lintRule && lintRule.uses.get('eslint')
let lintExtensions = arrify(lintRule && lintRule.get('test')).concat(LOADER_EXTENSIONS)
let staticDirPath = path.join(neutrino.options.source, 'static')

function mergeWith(options = {}){
return function(opts = {}){
return deepmerge(opts, options)
}
}

config
.devtool(devRun ? 'eval-source-map' : 'source-map')
Expand All @@ -37,13 +44,13 @@ module.exports = function (neutrino, options = {}) {
.add(require.resolve('./polyfills.js'))
.end()
.entry('index')
.add(neutrino.options.entry)
.add(neutrino.options.mains.index)
.end()
.output
.path(neutrino.options.output)
.publicPath('./')
.filename('[name].bundle.js')
.chunkFilename('[id].[chunkhash].js')
.chunkFilename('[name].[chunkhash].js')
.end()
.resolve.extensions
.add('.js')
Expand Down Expand Up @@ -83,6 +90,9 @@ module.exports = function (neutrino, options = {}) {
neutrino.options.tests,
require.resolve('./polyfills.js')
],
exclude: [
staticDirPath
],
targets: {
browsers: options.browsers
}
Expand All @@ -98,18 +108,19 @@ module.exports = function (neutrino, options = {}) {
if (!testRun) {
neutrino.use(chunk)
}

if (devRun) {
neutrino.use(devServer, merge({ public: true }, options.server || {}))
neutrino.use(devServer, deepmerge({ public: true }, options.server || {}))
}
else {
neutrino.use(progress)
neutrino.use(clean, { paths: [neutrino.options.output] })
neutrino.use(minify)
neutrino.use(copy, {
patterns: [{
context: neutrino.options.static,
context: staticDirPath,
from: '**/*',
to: path.basename(neutrino.options.static)
to: path.basename(staticDirPath)
}]
})
config.output.filename('[name].[chunkhash].bundle.js')
Expand All @@ -119,14 +130,14 @@ module.exports = function (neutrino, options = {}) {
lintRule
.pre()
eslintLoader
.tap(options => merge(options, {
.tap(mergeWith({
parserOptions: {
ecmaFeatures: {
experimentalObjectRestSpread: true
}
}
}))
.tap(options => merge(options, {
.tap(mergeWith(options, {
envs: ['browser', 'commonjs']
}))
}
Expand All @@ -136,7 +147,7 @@ module.exports = function (neutrino, options = {}) {
.pre()
.test(lintExtensions)
eslintLoader
.tap(options => merge(options, {
.tap(mergeWith(options, {
plugins: ['html'],
settings: {
'html/html-extensions': ['.html', '.htm', '.svelte', '.svlt']
Expand Down

0 comments on commit a5e7a26

Please sign in to comment.