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

upgrade to webpack 2 #53

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@
"scripts": {
"start": "webpack-dev-server --hot --inline",
"build": "rimraf dist && webpack && mv dist/*.eot dist/static/css/ && mv dist/*.woff* dist/static/css/ && mv dist/*.svg dist/static/css/ && mv dist/*.ttf dist/static/css/",
"reinstall": "npm i rimraf && rimraf node_modules && npm uninstall -g elm && npm i -g elm && npm i && elm package install"
"reinstall": "npm i rimraf && rimraf elm-stuff && rimraf node_modules && npm i && elm package install"
},
"devDependencies": {
"autoprefixer": "^6.3.6",
"bootstrap-sass": "^3.3.6",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.26.1",
"css-loader": "^0.26.2",
"elm": "^0.18.0",
"elm-hot-loader": "^0.5.4",
"elm-webpack-loader": "^4.1.1",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"html-webpack-plugin": "^2.17.0",
"elm-webpack-loader": "^4.2.0",
"extract-text-webpack-plugin": "^2.0.0",
"file-loader": "^0.10.1",
"html-webpack-plugin": "^2.28.0",
"jquery": "^3.1.0",
"node-sass": "^4.2.0",
"postcss-loader": "^1.1.1",
"rimraf": "^2.5.2",
"sass-loader": "^4.0.0",
"sass-loader": "^6.0.0",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1",
"webpack-merge": "^2.4.0"
"webpack": "^2.2.1",
"webpack-dev-server": "^2.4.1",
"webpack-merge": "^4.0.0"
}
}
5 changes: 5 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
plugins: [
require('autoprefixer')( { browsers: ['last 2 versions'] } )
]
}
41 changes: 22 additions & 19 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ var commonConfig = {

output: {
path: outputPath,
filename: `/static/js/${outputFilename}`,
// publicPath: '/'
filename: `static/js/${outputFilename}`,
publicPath: '/'
},

resolve: {
extensions: ['', '.js', '.elm']
extensions: ['.js', '.elm']
},

module: {
noParse: /\.elm$/,
loaders: [
rules: [
{
test: /\.(eot|ttf|woff|woff2|svg)$/,
loader: 'file-loader'
use: 'file-loader'
Copy link

Choose a reason for hiding this comment

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

I think this should still be loader. Check the // Do not use "use" here comment in the code block at https://webpack.js.org/guides/migrating/#module-loaders-is-now-module-rules

}
]
},
Expand All @@ -45,8 +45,6 @@ var commonConfig = {
})
],

postcss: [ autoprefixer( { browsers: ['last 2 versions'] } ) ],

}

// additional webpack settings for local env (when invoked by 'npm start')
Expand All @@ -67,15 +65,15 @@ if ( TARGET_ENV === 'development' ) {
},

module: {
loaders: [
rules: [
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/],
loader: 'elm-hot!elm-webpack?verbose=true&warn=true&debug=true'
loader: 'elm-hot-loader!elm-webpack-loader?verbose=true&warn=true&debug=true'
Copy link

Choose a reason for hiding this comment

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

Should probably use the new "array of object"-syntax

use: [
  {
    loader: 'elm-hot-loader'
  },
  {
    loader: 'elm-webpack-loader',
    options: {
      verbose: true,
      debug: true,
      warn: true,
    }
  }
]

},
{
test: /\.(css|scss)$/,
loaders: [
use: [
'style-loader',
'css-loader',
'postcss-loader',
Expand All @@ -97,19 +95,24 @@ if ( TARGET_ENV === 'production' ) {
entry: entryPath,

module: {
loaders: [
rules: [
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/],
loader: 'elm-webpack'
use: 'elm-webpack-loader'
Copy link

Choose a reason for hiding this comment

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

},
{
test: /\.(css|scss)$/,
loader: ExtractTextPlugin.extract( 'style-loader', [
'css-loader',
'postcss-loader',
'sass-loader'
])
use: ExtractTextPlugin.extract(
{
fallback: "style-loader",
use: [
'css-loader',
'postcss-loader',
'sass-loader'
],
allChunks: true
})
}
]
},
Expand All @@ -125,10 +128,10 @@ if ( TARGET_ENV === 'production' ) {
},
]),

new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
Copy link

Choose a reason for hiding this comment

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

This is on by default and can therefore be removed


// extract CSS into a separate file
new ExtractTextPlugin( 'static/css/[name]-[hash].css', { allChunks: true } ),
new ExtractTextPlugin( 'static/css/[name]-[hash].css'),
Copy link

Choose a reason for hiding this comment

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

I'm not sure if plain filename is supported, nor why you removed allChunks: true, but according to this, the new code should be

new ExtractTextPlugin({
  filename: 'static/css/[name]-[hash].css',
  allChunks: true
})


// minify & mangle JS/CSS
new webpack.optimize.UglifyJsPlugin({
Expand Down